1

Resolved

locale.setlocale does not detect/set default user locale

description

according to locale module documentation, the following:

import locale
locale.setlocale(locale.LC_ALL, '')

should set locale to the default user value ("An empty string specifies the user’s default settings.")
As far as I can tell, in case when all env variables are not set (LANG et al), it should be "C", but it is not.
At the same time when LANG is set to a reasonable value (e.g. en_US.UTF-8) it should respect it.
In both cases the locale is not set as expected.
In addition call to:
locale.getlocale()
throws:

Traceback (most recent call last):
File "", line 1, in
File "c:\github\IronLanguages\External.LCA_RESTRICTED\Languages\IronPython\27\Lib\locale.py", line 515, in getlocale
File "c:\github\IronLanguages\External.LCA_RESTRICTED\Languages\IronPython\27\Lib\locale.py", line 428, in _parse_localename
ValueError: unknown locale:

comments

paweljasinski wrote Oct 14, 2012 at 12:01 PM

I dig a bit deeper and I am wrong on the LANG thing. It is not obligatory.
It should be fine, as long as it respects user default setting and doesn't trigger exception when locale.getlocale() is called

jdhardy wrote May 11 at 6:21 AM

Fixed in 2371b5d.