Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85380 > unrolled thread

Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2015-02-09 16:02 +0000
Last post2015-02-09 16:02 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-09 16:02 +0000

#85380 — Re: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-02-09 16:02 +0000
SubjectRe: locale bug in Python 2.7, 3.3, 3.4 (Win7 64)?
Message-ID<mailman.18563.1423497772.18130.python-list@python.org>
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.

>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> 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?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

Those flaming Romans didn't get the locales right did they? :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web