Commit 4fcf39cf authored by Fredrik Lundh's avatar Fredrik Lundh

- repaired locale.py for non-windows platforms. the try/except

  checked for the wrong exception.  my fault.  sorry.
  (first reported by Alex Coventry)
parent 1059dc70
...@@ -282,16 +282,19 @@ def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): ...@@ -282,16 +282,19 @@ def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')):
be determined. be determined.
""" """
try: try:
# check if it's supported by the _locale module # check if it's supported by the _locale module
import _locale import _locale
code, encoding = _locale._getdefaultlocale() code, encoding = _locale._getdefaultlocale()
except (ImportError, AttributeError):
pass
else:
if sys.platform == "win32" and code and code[:2] == "0x": if sys.platform == "win32" and code and code[:2] == "0x":
# map windows language identifier to language name # map windows language identifier to language name
code = windows_locale.get(int(code, 0)) code = windows_locale.get(int(code, 0))
return code, encoding return code, encoding
except (ImportError, NameError):
pass
# fall back on POSIX behaviour # fall back on POSIX behaviour
import os import os
lookup = os.environ.get lookup = os.environ.get
......
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