locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?
Albert-Jan Roskam
fomcl at yahoo.com
Mon Feb 9 10:43:55 EST 2015
Hi,
In the locale module we have:
* setlocale, the setter that also returns something
* getlocale, the getter that returns the OS-specific locale tuple (supposedly!)
* getdefaultlocale, the getter that always returns a unix locale tuple
Why are the getlocale() results below sometimes windows-like, sometimes unix-like?
It seems that I need to use setlocale(), with only the 'category' parameter, right?
ActivePython 3.3.2.0 (ActiveState Software Inc.) based on
Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
(None, None) # because setocale has not been called yet
# works as expected
>>> locale.setlocale(locale.LC_ALL, "")
'Dutch_Netherlands.1252'
>>> locale.getlocale()
('Dutch_Netherlands', '1252')
# bug!>>> locale.setlocale(locale.LC_ALL, "german")
'German_Germany.1252'
>>> locale.getlocale()
('de_DE', 'cp1252') # incorect, unix-like!
>>> locale.setlocale(locale.LC_ALL, "German_Germany.1252")
'German_Germany.1252'
>>> locale.getlocale()
('de_DE', 'cp1252') # incorect, unix-like!
# bug!
>>> locale.setlocale(locale.LC_ALL, "spanish")
'Spanish_Spain.1252'
>>> locale.getlocale()
('es_ES', 'cp1252') # incorect, unix-like!
# works as expected
>>> locale.setlocale(locale.LC_ALL, "italian")
'Italian_Italy.1252'
>>> locale.getlocale()
('Italian_Italy', '1252') # correct!
# ... maybe more?
Regards,
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the Python-list
mailing list