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.

Title: setlocale regression
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.6
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\", line 513, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

I am using Python 2.6.2 on Windows XP 32 bits.

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")

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/'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")
>>> locale.setlocale(4, "fr")
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
( and 7
( it seems
that the behaviour in VS6 (and thus Python 2.5) was flawed. The
supported language options are listed at 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")

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.
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