Catch exception thrown on certain locale setup

Mostly happening on Mac. Will investigate later.

TBR=dpranke
BUG=
TEST=

Review URL: http://codereview.chromium.org/6696094

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79354 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/fix_encoding.py b/fix_encoding.py
index 5bfb58e..ab41869 100644
--- a/fix_encoding.py
+++ b/fix_encoding.py
@@ -46,17 +46,23 @@
     if attr[0:3] != 'LC_':
       continue
     aref = getattr(locale, attr)
-    locale.setlocale(aref, '')
+    try:
+      locale.setlocale(aref, '')
+    except locale.Error:
+      continue
     try:
       lang = locale.getlocale(aref)[0]
     except (TypeError, ValueError):
-      lang = None
+      continue
     if lang:
       try:
         locale.setlocale(aref, (lang, 'UTF-8'))
       except locale.Error:
         os.environ[attr] = lang + '.UTF-8'
-  locale.setlocale(locale.LC_ALL, '')
+  try:
+    locale.setlocale(locale.LC_ALL, '')
+  except locale.Error:
+    pass
   return True