Issue #1813: Fix codec lookup and setting/getting locales under Turkish locales.
diff --git a/Lib/locale.py b/Lib/locale.py
index bb4aa37..166538d 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -331,6 +331,13 @@
# 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 @@
"""
# 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(':', '.')