New submission from albertjan:
getlocale() is supposed to (?) return a locale two-tuple in a platform-specific
notation. However, in *Windows* 7 64, with Python 3.4, 3.3 and 2.7 a
*unix-like*, abbreviated, lang_territory notation is used for french, german,
portuguese, spanish. In other words: In these four cases, the output of
setlocale is not equal to ".".join(locale.getlocale())
## Code that demonstrates the differences
from __future__ import print_function
import locale
import collections
import pprint
languages = ("chinese czech danish dutch english finnish french german greek "
"hungarian icelandic italian japanese korean norwegian polish "
"portuguese russian slovak spanish swedish turkish")
d = collections.defaultdict(list)
t = collections.namedtuple("Locale", "lang setlocale getlocale")
for language in languages.split():
sloc = locale.setlocale(locale.LC_ALL, language)
gloc = locale.getlocale()
record = t(language, sloc, gloc)
if gloc[0][2] == "_":
d["unix-like"].append(record)
else:
d["windows-like"].append(record)
pprint.pprint(dict(d))
## output
n:\>C:\Miniconda3\python.exe N:\temp\loc.py
-------------------------------------------------------------
{'unix-like': [Locale(lang='french', setlocale='French_France.1252',
getlocale=('fr_FR', 'cp1252')),
Locale(lang='german', setlocale='German_Germany.1252',
getlocale=('de_DE', 'cp1252')),
Locale(lang='portuguese', setlocale='Portuguese_Brazil.1252',
getlocale=('pt_BR', 'cp1252')),
Locale(lang='spanish', setlocale='Spanish_Spain.1252',
getlocale=('es_ES', 'cp1252'))],
-------------------------------------------------------------
'windows-like': [Locale(lang='chinese', setlocale="Chinese
(Simplified)_People's Republic of China.936", getlocale=("Chinese
(Simplified)_People's Republic of China", '936')),
Locale(lang='czech', setlocale='Czech_Czech Republic.1250',
getlocale=('Czech_Czech Republic', '1250')),
Locale(lang='danish', setlocale='Danish_Denmark.1252',
getlocale=('Danish_Denmark', '1252')),
Locale(lang='dutch', setlocale='Dutch_Netherlands.1252',
getlocale=('Dutch_Netherlands', '1252')),
Locale(lang='english', setlocale='English_United
States.1252', getlocale=('English_United States', '1252')),
Locale(lang='finnish', setlocale='Finnish_Finland.1252',
getlocale=('Finnish_Finland', '1252')),
Locale(lang='greek', setlocale='Greek_Greece.1253',
getlocale=('Greek_Greece', '1253')),
Locale(lang='hungarian', setlocale='Hungarian_Hungary.1250',
getlocale=('Hungarian_Hungary', '1250')),
Locale(lang='icelandic', setlocale='Icelandic_Iceland.1252',
getlocale=('Icelandic_Iceland', '1252')),
Locale(lang='italian', setlocale='Italian_Italy.1252',
getlocale=('Italian_Italy', '1252')),
Locale(lang='japanese', setlocale='Japanese_Japan.932',
getlocale=('Japanese_Japan', '932')),
Locale(lang='korean', setlocale='Korean_Korea.949',
getlocale=('Korean_Korea', '949')),
Locale(lang='norwegian', setlocale='Norwegian
(Bokmål)_Norway.1252', getlocale=('Norwegian (Bokmål)_Norway', '1252')),
Locale(lang='polish', setlocale='Polish_Poland.1250',
getlocale=('Polish_Poland', '1250')),
Locale(lang='russian', setlocale='Russian_Russia.1251',
getlocale=('Russian_Russia', '1251')),
Locale(lang='slovak', setlocale='Slovak_Slovakia.1250',
getlocale=('Slovak_Slovakia', '1250')),
Locale(lang='swedish', setlocale='Swedish_Sweden.1252',
getlocale=('Swedish_Sweden', '1252')),
Locale(lang='turkish', setlocale='Turkish_Turkey.1254',
getlocale=('Turkish_Turkey', '1254'))]}
----------
components: Library (Lib)
messages: 235630
nosy: [email protected]
priority: normal
severity: normal
status: open
title: Windows getlocale unix-like with french, german, portuguese, spanish
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23425>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com