Closed mike-fabian closed 3 years ago
It ignores all modifiers except @euro:
$ LC_ALL=de_DE python3
Python 3.9.5 (default, May 14 2021, 00:00:00)
[GCC 11.1.1 20210428 (Red Hat 11.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale(category=locale.LC_CTYPE)
('de_DE', 'ISO8859-1')
>>>
$ LC_ALL=de_DE@euro python3
Python 3.9.5 (default, May 14 2021, 00:00:00)
[GCC 11.1.1 20210428 (Red Hat 11.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale(category=locale.LC_CTYPE)
('de_DE', 'ISO8859-15')
>>>
$ LC_ALL=ks_IN python3
Python 3.9.5 (default, May 14 2021, 00:00:00)
[GCC 11.1.1 20210428 (Red Hat 11.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale(category=locale.LC_CTYPE)
('ks_IN', 'UTF-8')
>>>
$ LC_ALL=ks_IN@devanagari python3
Python 3.9.5 (default, May 14 2021, 00:00:00)
[GCC 11.1.1 20210428 (Red Hat 11.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale(category=locale.LC_CTYPE)
('ks_IN', 'UTF-8')
>>>
$
https://github.com/python/cpython/blob/main/Lib/locale.py#L385 :
def _append_modifier(code, modifier):
if modifier == 'euro':
if '.' not in code:
return code + '.ISO8859-15'
_, _, encoding = code.partition('.')
if encoding in ('ISO8859-15', 'UTF-8'):
return code
if encoding == 'ISO8859-1':
return _replace_encoding(code, 'ISO8859-15')
return code + '@' + modifier
https://github.com/python/cpython/blob/main/Lib/locale.py#L479
if '@' in code:
# Deal with locale modifiers
code, modifier = code.split('@', 1)
if modifier == 'euro' and '.' not in code:
# Assume Latin-9 for @euro locales. This is bogus,
# since some systems may use other encodings for these
# locales. Also, we ignore other modifiers.
return code, 'iso-8859-15'
https://docs.python.org/3/library/locale.html says:
locale.getlocale(category=LC_CTYPE)
That doesn’t return the @devanagari !