Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0466132

Browse files
author
Fredrik Lundh
committed
- repaired locale.py for non-windows platforms. the try/except
checked for the wrong exception. my fault. sorry. (first reported by Alex Coventry)
1 parent b781655 commit 0466132

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/locale.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,19 @@ def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')):
282282
be determined.
283283
284284
"""
285+
285286
try:
286287
# check if it's supported by the _locale module
287288
import _locale
288289
code, encoding = _locale._getdefaultlocale()
290+
except (ImportError, AttributeError):
291+
pass
292+
else:
289293
if sys.platform == "win32" and code and code[:2] == "0x":
290294
# map windows language identifier to language name
291295
code = windows_locale.get(int(code, 0))
292296
return code, encoding
293-
except (ImportError, NameError):
294-
pass
297+
295298
# fall back on POSIX behaviour
296299
import os
297300
lookup = os.environ.get

0 commit comments

Comments
 (0)