Issue 6668: locale.py: can't parse sr_RS@latin locale (original) (raw)
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).
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'