Commit cfa826c9 authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent 3e331bdf
...@@ -46,17 +46,23 @@ def fix_default_encoding(): ...@@ -46,17 +46,23 @@ def fix_default_encoding():
if attr[0:3] != 'LC_': if attr[0:3] != 'LC_':
continue continue
aref = getattr(locale, attr) aref = getattr(locale, attr)
locale.setlocale(aref, '') try:
locale.setlocale(aref, '')
except locale.Error:
continue
try: try:
lang = locale.getlocale(aref)[0] lang = locale.getlocale(aref)[0]
except (TypeError, ValueError): except (TypeError, ValueError):
lang = None continue
if lang: if lang:
try: try:
locale.setlocale(aref, (lang, 'UTF-8')) locale.setlocale(aref, (lang, 'UTF-8'))
except locale.Error: except locale.Error:
os.environ[attr] = lang + '.UTF-8' os.environ[attr] = lang + '.UTF-8'
locale.setlocale(locale.LC_ALL, '') try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
pass
return True return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment