mirror of
https://github.com/python/cpython.git
synced 2025-08-17 23:31:09 +00:00
Issue #1813: Fix codec lookup and setting/getting locales under Turkish locales.
This commit is contained in:
parent
a620facc1f
commit
4cfae027b3
5 changed files with 39 additions and 2 deletions
|
@ -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(':', '.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue