Author serhiy.storchaka
Recipients lemburg, loewis, serhiy.storchaka
Date 2013-12-28.09:44:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388223842.98.0.521951916148.issue20088@psf.upfronthosting.co.za>
In-reply-to
Content
>>> import locale, _locale
>>> _locale.setlocale(locale.LC_CTYPE, 'en_AG')
'en_AG'
>>> _locale.setlocale(locale.LC_CTYPE)
'en_AG'
>>> locale.getlocale(locale.LC_CTYPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/locale.py", line 575, in getlocale
    return _parse_localename(localename)
  File "/home/serhiy/py/cpython/Lib/locale.py", line 484, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: en_AG

One solution is proposed in issue20079: map all supported in glibc locale names without encoding to locale names with encoding. But see issue20087. And default encoding can be different on other systems (not based on glibc).

Other solution is not guess an encoding, but use locale.nl_langinfo(locale.CODESET) in locale.getlocale(). And left in locale alias table only nonstandard mappings (such as english_uk -> en_GB.ISO8859-1 and sr_yu.iso88595 -> sr_CS.ISO8859-5).
History
Date User Action Args
2013-12-28 09:44:03serhiy.storchakasetrecipients: + serhiy.storchaka, lemburg, loewis
2013-12-28 09:44:02serhiy.storchakasetmessageid: <1388223842.98.0.521951916148.issue20088@psf.upfronthosting.co.za>
2013-12-28 09:44:02serhiy.storchakalinkissue20088 messages
2013-12-28 09:44:02serhiy.storchakacreate