diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-24 02:51:01 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-24 02:51:01 +0200 |
commit | 4cfae027b39d14a5a43f337c1a38b42d7461dd3a (patch) | |
tree | a099cd8fcaabaf4c6cb3aff1e686bcae50f745f6 /Lib/locale.py | |
parent | a620facc1f66654c1b3337ed6d7dfa158cfaf8f2 (diff) | |
download | cpython-git-4cfae027b39d14a5a43f337c1a38b42d7461dd3a.tar.gz |
Issue #1813: Fix codec lookup and setting/getting locales under Turkish locales.
Diffstat (limited to 'Lib/locale.py')
-rw-r--r-- | Lib/locale.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py index bb4aa37b29..166538d270 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -331,6 +331,13 @@ def _test(): # overridden below) _setlocale = setlocale +# Avoid relying on the locale-dependent .lower() method +# (see issue #1813). +_ascii_lower_map = ''.join( + chr(x + 32 if x >= ord('A') and x <= ord('Z') else x) + for x in range(256) +) + def normalize(localename): """ Returns a normalized locale code for the given locale @@ -348,7 +355,7 @@ def normalize(localename): """ # Normalize the locale name and extract the encoding - fullname = localename.lower() + fullname = localename.translate(_ascii_lower_map) if ':' in fullname: # ':' is sometimes used as encoding delimiter. fullname = fullname.replace(':', '.') |