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
experimental/szager/collated-output
maruel@chromium.org 14 years ago
parent 3e331bdf16
commit cfa826c984

@ -46,17 +46,23 @@ def fix_default_encoding():
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

Loading…
Cancel
Save