[ python-Bugs-1080864 ] locale.py doesn't recognize valid locale setting

SourceForge.net noreply at sourceforge.net
Wed Dec 8 00:08:32 CET 2004


Bugs item #1080864, was opened at 2004-12-07 21:23
Message generated for change (Comment added) made by lemburg
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1080864&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: stas Z (childsplay)
Assigned to: Nobody/Anonymous (nobody)
Summary: locale.py doesn't recognize valid locale setting

Initial Comment:
stas at mobi:~$ locale
LANG=nb_NO
[...]

stas at 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
>>> 

----------------------------------------------------------------------

>Comment By: M.-A. Lemburg (lemburg)
Date: 2004-12-08 00:08

Message:
Logged In: YES 
user_id=38388

Of course, I don't agree with you, Martin :-)
locale.getdefaultlocale() does server a purpose, namely that
of getting the default locale setting. The encoding
information is an often used extension when setting the
locale in the OS environment. If not set, the module
provides common defaults.

The locale "nb_NO" is not known to the module alias table.
Which locale, language and encoding would that be ?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-12-07 23:13

Message:
Logged In: YES 
user_id=21627

To get the default encoding for the current locale, you
should use locale.getpreferredencoding(). You should not use
getdefaultlocale becaus it is (IMO) inherently broken, and
should not have been part of the standard library in the
first place.

----------------------------------------------------------------------

Comment By: Jarek Zgoda (zgoda)
Date: 2004-12-07 22:39

Message:
Logged In: YES 
user_id=92222

getdefaultlocale() is often used to get default encoding for
current system locale.
And, if function is provided in standard library, why
shouldn't one use it?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-12-07 21:25

Message:
Logged In: YES 
user_id=21627

Why do you want to use getdefaultlocale()?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1080864&group_id=5470


More information about the Python-bugs-list mailing list