New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
locale.py doesn't recognize valid locale setting #41296
Comments
stas@mobi:~$ locale stas@mobi:~$ python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import locale
>>> locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/locale.py", line 346, in
getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python2.3/locale.py", line 280, in
_parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: nb_NO
>>> |
Logged In: YES Why do you want to use getdefaultlocale()? |
Logged In: YES getdefaultlocale() is often used to get default encoding for |
Logged In: YES To get the default encoding for the current locale, you |
Logged In: YES Of course, I don't agree with you, Martin :-) The locale "nb_NO" is not known to the module alias table. |
Logged In: YES There is no "default locale setting" in most operating |
Logged In: YES The LANG (and other similar OS environment variables) define On some OSes such as Windows these settings are stored |
Logged In: YES The reason I use getdefaultlocale(), is to get a platform |
Logged In: YES Please provide some authorative source which describes the |
Logged In: YES This is what I've put into /python2.3/locale.py: locale_alias = {....
.......
'bokmål': 'nb_NO.ISO8859-1',
'nb': 'nb_NO.ISO8859-1',
'nb_no': 'nb_NO.ISO8859-1',
'nynorsk': 'nn_NO.ISO8859-1',
'nn': 'nn_NO.ISO8859-1',
'nn_no': 'nn_NO.ISO8859-1',
....
....
} I have tested it on a number of apps and it fixes the problem. |
Logged In: YES MAL: that doesn't answer my question, though: In what sense childsplay: the problem with adding additional aliases is |
Logged In: YES I agree that "default" would probably be called "preferred". @loewis: b) BTW: getting the current locale to get a platform |
Logged In: YES Martin: "default" as opposed to whatever locale setting is currently getdefaultlocale() mimics the lookup mechanism of The fact that the alias table may sometimes not give the Note that this is different than the "preferred" encoding |
Logged In: YES childsplay (I wish people would use real names on SF...): We can add the aliases you gave below, but we need some URLs Thanks. |
Logged In: YES getdefaultencoding might be "targeted" at the OS level - but |
Logged In: YES Well, if the alias mapping is good enough for X, then it's I think we ought to update the alias table with the current There also seems to be a bug in the encoding alias table: I'll fix that and post an update here. |
Logged In: YES Checking in Lib/locale.py; |
Logged In: YES I've looked at the CVS/locale.py but is the utf8 entry missing? |
Logged In: YES Thanks. I've noticed that the C lib doesn't seem to like Checking in Lib/locale.py; Please check again with the updated version. |
Logged In: YES Checked and it works ok, thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: