This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: locale.py: can't parse sr_RS@latin locale
Type: behavior Stage: test needed
Components: Library (Lib), Unicode Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: VPeric, lemburg, loewis, r.david.murray
Priority: normal Keywords:

Created on 2009-08-07 14:34 by VPeric, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg91404 - (view) Author: Vlada Peric (VPeric) Date: 2009-08-07 14:34
The sr_RS locale in glibc corresponds to the Cyrillic script, while the 
agreed upon locale for the Latin alphabet is sr_RS@latin. Unfortunately, 
the locale python module crashes when trying to parse this locale. Here 
is the traceback:

File "/usr/lib/python2.6/locale.py", line 497, in get locale
  return _parse_localename(localename)
File "usr/lib/python2.6/locale.py", line 410, in _parse_localename
  raise ValueError, 'unknown locale: %s' % localename

Looking at the code, it only checks for the @euro modifier and ignores 
all other modifiers (including @latin). This is all when I set 
LANG=sr_RS@latin. If I use LANG=sr_RS.UTF8@latin (also allowed by 
glibc), Python interprets this as the sr_RS locale (which is wrong, as 
that is for Cyrillic).
msg110166 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-07-13 09:56
This should be fixed in Python 2.7. It added a few more aliases:

    'sr_rs':                                'sr_RS.UTF-8',
    'sr_rs.utf8@latn':                      'sr_RS.UTF-8@latin',
    'sr_rs@latin':                          'sr_RS.UTF-8@latin',
    'sr_rs@latn':                           'sr_RS.UTF-8@latin',
msg119433 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-23 15:27
Python 3.2a3+ (py3k:85670:85675M, Oct 17 2010, 20:27:19) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL)
'LC_CTYPE=sr_RS@latin;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C'


rdmurray@hey:~/maestro/python/release31-maint>LC_ALL="sr_RS@latin" ./python
Python 3.1.2 (release31-maint:85675M, Oct 17 2010, 20:16:54) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL)
'LC_CTYPE=sr_RS@latin;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C'


rdmurray@hey:~/maestro/python/release27-maint>LC_ALL="sr_RS@latin" ./python
Python 2.7.0+ (release27-maint:85802, Oct 23 2010, 11:15:26) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL)
'C'
>>> locale.setlocale(locale.LC_ALL, 'sr_RS@latin')
'sr_RS@latin'
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50917
2010-10-23 15:27:31r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg119433

resolution: fixed
2010-07-13 09:56:58lemburgsetmessages: + msg110166
2010-07-11 13:54:09brian.curtinsetnosy: lemburg, loewis, VPeric
components: + Unicode
2010-07-11 13:30:34BreamoreBoysetnosy: + loewis, lemburg
stage: test needed

components: + Library (Lib), - Unicode
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2010-02-09 16:54:13brian.curtinsettype: crash -> behavior
2009-08-07 14:34:33VPericcreate