This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: setlocale regression
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Kerfred, asmodai, georg.brandl, loewis, ocean-city
Priority: normal Keywords:

Created on 2009-05-06 13:22 by Kerfred, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg87331 - (view) Author: (Kerfred) Date: 2009-05-06 13:22
There is a regression bug between Python 2.5 and Python 2.6.

With Python 2.5, the following code works:
import locale
locale.setlocale(locale.LC_ALL, 'fr')

Whereas with Python 2.6, I get this message:
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python26\Lib\locale.py", line 513, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

I am using Python 2.6.2 on Windows XP 32 bits.

Regards,
Fred
--
msg87334 - (view) Author: Jeroen Ruigrok van der Werven (asmodai) * (Python committer) Date: 2009-05-06 14:19
I can verify this on Vista.

2.5 gives:

>>> from locale import setlocale, LC_ALL
>>> setlocale(LC_ALL, "fr")
'French_France.1252'

Whereas 2.6 fails.

There is no difference between 2.5's and 2.6's PyLocale_setlocale() from
what I can see in Modules/_localemodule.c.
Also Lib/locale.py's setlocale() in both versions is identical from what
I can see.
msg87341 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-05-06 16:54
Did you build python from source? Or did you download official binary
distribution? If latter, Python2.5 was built with VC7, and Python2.6 is
built with VC9. Probably difference of behavior comes from difference of
version of msvcrt.

I ran following codes from my python2.6 built from source with VC6, and
I succeeded to set locale.

Python 2.6.2c1 (release26-maint, Apr 11 2009, 07:01:50) [MSC v.1200 32
bit (Inte
l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(4, "ja")
'Japanese_Japan.932'
>>> locale.setlocale(4, "fr")
'French_France.1252'
msg87342 - (view) Author: Jeroen Ruigrok van der Werven (asmodai) * (Python committer) Date: 2009-05-06 17:45
My tests were with official distributions.

Yamamoto-san, thank you for your testing. I was thinking it might have
been something to do with changed semantics, but I am happy you saved me
the time from having to compile.

Looking at the documentation for setlocale() in VS6
(http://msdn.microsoft.com/en-us/library/aa272906(VS.60).aspx) and 7
(http://msdn.microsoft.com/en-us/library/x99tb11d(VS.71).aspx) it seems
that the behaviour in VS6 (and thus Python 2.5) was flawed. The
supported language options are listed at
http://msdn.microsoft.com/en-us/library/aa246450(VS.60).aspx and they do
not list a "fr" combination. It seems the possibility of "fr" working
might have been a remnant or a bug. The appropriate language designation
should have been "fra" for the default French locale.

From my 2.6 interpreter:

>>> setlocale(LC_ALL, "fra")
'French_France.1252'

So this is all intended behaviour and not a bug with Python. As such I
propose to close it.
msg87349 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-05-06 21:30
Closing as "won't fix", then.
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50198
2009-05-06 21:30:34georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg87349

resolution: wont fix
2009-05-06 21:05:40loewissetassignee: loewis ->
2009-05-06 17:45:35asmodaisetmessages: + msg87342
2009-05-06 16:58:58ocean-citysetassignee: loewis
2009-05-06 16:54:55ocean-citysetassignee: loewis -> (no value)

messages: + msg87341
nosy: + ocean-city
2009-05-06 16:27:25georg.brandlsetassignee: loewis

nosy: + loewis
2009-05-06 14:19:42asmodaisetnosy: + asmodai
messages: + msg87334
2009-05-06 13:22:54Kerfredcreate