Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85402
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fomcl@yahoo.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'win32': 0.03; 'skip:[ 20': 0.04; 'output': 0.05; 'subject:Python': 0.06; 'subject:bug': 0.07; 'url:msdn': 0.07; 'imho.': 0.09; 'lawrence': 0.09; 'locale': 0.09; 'none)': 0.09; 'polish': 0.09; 'subject:2.7': 0.09; 'python': 0.11; 'bug': 0.12; 'suggest': 0.14; '2.7': 0.14; 'windows': 0.15; '(none,': 0.16; '3.3,': 0.16; '__future__': 0.16; 'collections': 0.16; 'czech': 0.16; 'finnish': 0.16; 'inc.)': 0.16; 'incorrect': 0.16; 'italian': 0.16; 'language)': 0.16; 'subject:)?': 0.16; 'subject:3.3': 0.16; 'tuple': 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'have:': 0.19; 'seems': 0.21; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'skip:l 30': 0.24; 'tracker': 0.26; 'skip:" 20': 0.27; 'header:In-Reply- To:1': 0.27; 'record': 0.27; 'to:2**1': 0.27; 'unix': 0.29; 'skip:g 30': 0.30; 'skip:( 20': 0.30; "skip:' 10": 0.31; '"")': 0.31; 'loads': 0.31; 'portuguese': 0.31; 'sep': 0.31; 'though.': 0.31; 'checked': 0.32; 'languages': 0.32; 'skip:c 30': 0.32; 'open': 0.33; '-----': 0.33; 'bugs': 0.33; 'monday,': 0.33; 'maybe': 0.34; 'skip:d 20': 0.34; 'subject: (': 0.35; 'problem.': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'german': 0.35; 'there': 0.35; '8bit%:9': 0.36; 'right?': 0.36; 'doing': 0.36; 'useful': 0.36; 'hi,': 0.36; 'reports': 0.37; 'url:microsoft': 0.37; 'email addr:python.org': 0.37; 'expected': 0.38; 'sometimes': 0.38; 'others.': 0.38; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'issue': 0.38; 'little': 0.38; 'does': 0.39; 'subject:': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'received:67.195': 0.60; 'received:98.137': 0.60; 'french': 0.61; 're:': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'email name:python-list': 0.65; 'here': 0.66; 'header:Reply-To:1': 0.67; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'url:en-us': 0.68; 'results': 0.69; 'url:%1': 0.72; 'russian': 0.74; '2015': 0.84; '3.4': 0.84; 'bug!': 0.84; 'greek': 0.84; 'more?': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'to:addr:yahoo.co.uk': 0.84; '2013,': 0.91; 'dutch': 0.91; 'norwegian': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1423514331; bh=hAYFb/tFxFjOAsOXHz8+HVOgJ+SLROjix/sZ2x0eZUQ=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=c9DdYqRbhR+f4/QQpGB4PqRFo3Ny7QZwjDV7CaSii5CvXrVfJLxQ/wCAqllkK4U33gGpAVupbglJBmncvpczOtuFwkkQYvH8x2U1OA4CvIiawiE60XuwR8DptSVQUGfxuIbTTU3nWB97bHb2PjmzCB3yfrYJeg3OnVriKzLXABx8snEAB0q9ZJoi33Qu29RK0ldeVAks8Fl3lshPW5yImx2FoXLld6mpNmxcoaA1yOhD54+QnZnjlEqORURgpFbVugtZKIcr3Jh/5gPWt+oVBXpE0RTqLuROv4G1E6D63EFoa8NmRM9LF6N68k8pVMM72GIEAwBDj0ErN4Ksnu7beQ== |
| X-Yahoo-Newman-Property | ymail-4 |
| X-Yahoo-Newman-Id | 281608.78298.bm@omp1046.mail.gq1.yahoo.com |
| X-YMail-OSG | ClE1N84VM1mSlR3hwuNWGuEUfv6WPbfW7hxaMH6H2oGunTU1m3rSdQg4Z73P7pO oF9wZbpZr0nwmkqb9_hCz0aZnqPe_HyeE2jHsFugzTQrbt0_d6o7MShime9sv5wy4cAvdAuFWboc lhQJ2D5RD4866z0zR9K00bYg8MTqBrJ2yy0q7.OEKf21U2KNj7aiGmECpp8aD4C0I8EpH49po3kQ LAX7ezobE6A0pJ2uVJFb6mxO1BFphnFFebMDC3puJ0S5aNQsTHUk3ELmT7NMsSCnyjQiZTbGK.eY 93usIpZGCP0.9iO36.AQiWwr2mInA.Bok6xbuKZf.GPYXGR14J4WnL7VL9Ihj5uF3Gq3Pexy9tUh CUj2w8RFoatmYw22WtySL2oF9JGY_or4VwUytvyyJeenFRr.p_B7fYZuB_pDKw2sZEWibgBW0M0p tj4Koz968B0QZMfoEKA0wgqtDlBtP6fLuPyPjt3tDIokmMja368VOzGdmj891wFA6SQR6mIkWChL W.lQBcWD5rK0a9l6u09gkziNVQ4C.TqWas0xCqFcoAfgtAuh35vqJfS1vnjVEMqEyuG8JQGtUAQf _W_6GQ4ayjMbc0Y6874qOAQfBTBfrTZvOY1BWhWG6xpRfqisfDdIfv4IW0MqzAm_a3XTgoVT2JxE 26ADr7iM- |
| Date | Mon, 9 Feb 2015 20:35:49 +0000 (UTC) |
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| To | Mark Lawrence <breamoreboy@yahoo.co.uk>, "python-list@python.org" <python-list@python.org> |
| In-Reply-To | <mbaln0$vgp$1@ger.gmane.org> |
| References | <mbaln0$vgp$1@ger.gmane.org> |
| Subject | Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)? |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Albert-Jan Roskam <fomcl@yahoo.com> |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18577.1423514509.18130.python-list@python.org> (permalink) |
| Lines | 168 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423514509 news.xs4all.nl 2908 [2001:888:2000:d::a6]:46664 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85402 |
Show key headers only | View raw
----- Original Message -----
> From: Mark Lawrence <breamoreboy@yahoo.co.uk>
> To: python-list@python.org
> Cc:
> Sent: Monday, February 9, 2015 5:02 PM
> Subject: Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?
>
> On 09/02/2015 15:43, Albert-Jan Roskam wrote:
>> 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
>>
>
> There have been loads of bug reports on the issue tracker about locales.
> I suggest that you take a look to see if there is an open issue about
> this problem.
Hi Mark -Thanks! I checked the bug tracker. Lots of locale-related bugs indeed. I couldn't find this one though. Strange because what I am doing does not seem exotic at all. French, German, Portuguese and Spanish getlocale results are incorrect IMHO. Below is little check + output here in case it might be useful for others. This is with Python 3.4, 3.3 and 2.7 on Windows 7 64.
from __future__ import print_function
import locale
import collections
import pprint
#https://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.80%29.aspx
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))
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'))]}
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)? Albert-Jan Roskam <fomcl@yahoo.com> - 2015-02-09 20:35 +0000
csiph-web