[ python-Bugs-504219 ] locale.resetlocale is broken

SourceForge.net noreply at sourceforge.net
Mon Nov 8 19:59:11 CET 2004


Bugs item #504219, was opened at 2002-01-16 05:56
Message generated for change (Comment added) made by jlgijsbers
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=504219&group_id=5470

Category: Windows
>Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Syver Enstad (syvere)
Assigned to: Mark Hammond (mhammond)
>Summary: locale.resetlocale is broken

Initial Comment:
locale.setlocale doesn't recognize the the format that 
locale.py uses to set the locale, ie. no_NO and 
friends.

The only way I've succeeded in setting the locale on 
Python 2.1 is to use the format described in the 
Visual C++ C-runtime library docs for setlocale where 
a more verbose format is used to set the locale.

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

>Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-11-08 19:59

Message:
Logged In: YES 
user_id=469548

Still reproducible with Python 2.4:

Python 2.4b2 (#19, Nov  8 2004, 11:15:07)
[GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import locale
>>> locale.getdefaultlocale()
['en_US', 'utf']
>>> locale.resetlocale()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/johannes/python/Lib/locale.py", line 389, in
resetlocale
    _setlocale(category, _build_localename(getdefaultlocale()))
locale.Error: unsupported locale setting

Note that if I run python with 'LANG=nl_NL python', the
error does not occur.

http://python.org/sf/813449 seems to be the same bug, BTW.

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

Comment By: Syver Enstad (syvere)
Date: 2002-01-16 14:39

Message:
Logged In: YES 
user_id=428736

Sorry, I forgot to mention the testcase I am using. The 
test case that fails is the locale module itself, when 
running it as a standalone application that is.

To be more specific:
  File &quot;d:\devtools\python21\lib\locale.py&quot;, line 384, in 
resetlocale
    _setlocale(category, _build_localename(getdefaultlocale
()))
locale.Error: locale setting not supported

And to clarify what input getdefaultlocale returns on my 
machine:

&gt;&gt;&gt; locale.getdefaultlocale()
('no_NO', 'cp1252')

and:
&gt;&gt;&gt; locale._build_localename(locale.getdefaultlocale())
'no_NO.cp1252'

By the way, is this bug fixed in python 2.2?


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

Comment By: Martin v. Löwis (loewis)
Date: 2002-01-16 12:50

Message:
Logged In: YES 
user_id=21627

Can you provide a detailed test case? AFAIK, no_NO is indeed
no supported locale name on Windows, and I don't think
Python aanywhere uses it without the application explicitly
saying so.

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

Comment By: Tim Peters (tim_one)
Date: 2002-01-16 06:07

Message:
Logged In: YES 
user_id=31435

Mark, know anything about this?  I don't.

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

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


More information about the Python-bugs-list mailing list