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 <>
>>> import locale, _locale
>>> _locale.setlocale(locale.LC_CTYPE, 'en_AG')
>>> _locale.setlocale(locale.LC_CTYPE)
>>> locale.getlocale(locale.LC_CTYPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/", line 575, in getlocale
    return _parse_localename(localename)
  File "/home/serhiy/py/cpython/Lib/", 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).
Date User Action Args
2013-12-28 09:44:03serhiy.storchakasetrecipients: + serhiy.storchaka, lemburg, loewis
2013-12-28 09:44:02serhiy.storchakasetmessageid: <>
2013-12-28 09:44:02serhiy.storchakalinkissue20088 messages
2013-12-28 09:44:02serhiy.storchakacreate