[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2019-09-11 Thread Steve Dower


Steve Dower  added the comment:

issue37945 is a duplicate and has more up-to-date information on it, so I'm 
going to close this one even though it's older.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_locale failing

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2019-08-23 Thread Vidar Fauske


Vidar Fauske  added the comment:

Note that this is still an issue on Windows:

>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')
>>> locale.setlocale(locale.getdefaultlocale())
Error: unsupported locale setting

--
components: +Windows
nosy: +paul.moore, steve.dower, vidartf, zach.ware
versions: +Python 3.7 -Python 3.1, Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2015-08-25 Thread Gabi Davar

Changes by Gabi Davar grizzly@gmail.com:


--
nosy: +Gabi.Davar

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2014-06-12 Thread R. David Murray

R. David Murray added the comment:

See issue 21731 for considering putting a workaround for this into the calendar 
module (noted here because of msg122065).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2014-06-12 Thread R. David Murray

R. David Murray added the comment:

Oh, I see I'd already previously opened issue 10498 for that.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2011-05-15 Thread Tim Lyons

Tim Lyons guy.lin...@gmail.com added the comment:

Surely the user of getlocale as the right to expect that the same thing (i.e. 
ISO language codes) would be returned on all platforms. I am looking at some 
code that provides special purpose date handling routines. The appropriate 
routine is selected by a language code (for the locale category LC_TIME as it 
happens) like fr_FR. In order  to get this to work on different platforms, you 
have to test whether it is windows, and if so use getdefaultlocale, while for 
other platforms, you use getlocale in order to return similar language codes. 
This code would actually be wrong if the application were to change the locale 
inside the application, because on other platforms the change would have an 
effect, while on windows, it would be ignored! [I am running on Mac OS X as it 
happens, not Linux or Windows].
 
So, don’t say that getdefaultloale is not useful, it is the one that is needed 
on Windows!
 
Note this is not a problem with the encoding – some of the discussion and many 
of the related bugs are concerned with the encoding.
 
Also note Marc-Andre pointing out in 
http://mail.python.org/pipermail/python-bugs-list/2004-December/026667.html 
that “getdefaultlocale() mimics the lookup mechanism of setlocale(LC_ALL, )”. 
I recognise that he is talking about the lookup mechanism rather than the 
results, but it seems to suggest that the results might be similar (if you do 
the same lookup you would get the same result). But “getdefaultlocale returns 
something that setlocale cannot consume on Windows”!

I recognise that it would be difficult to decide to code locale on python so 
that windows returns something that is not the same as the native call, but it 
does seem to me that python locale should translate the Windows language codes 
so that they are the same as are returned on all the other platforms (i.e. ISO 
codes etc).

--
nosy: +guy.linton

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2011-05-07 Thread Jan Killian

Changes by Jan Killian jan.kill...@gmail.com:


--
nosy: +iki

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-23 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

R. David Murray wrote:
 
 R. David Murray rdmur...@bitdance.com added the comment:
 
 I had a report from a user on IRC during the bug weekend that they could not 
 reproduce the failure on windows.  So it may be dependent on the windows 
 version.  That doesn't answer your question of why it hasn't come up before, 
 though, since my tests were done on XP.

Some research shows that the MS VCRT uses non-ISO locale names
for setlocale():

http://msdn.microsoft.com/en-us/library/x99tb11d.aspx
http://msdn.microsoft.com/en-us/library/hzz3tw78.aspx
http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx
http://msdn.microsoft.com/en-us/library/cdax410z.aspx

and it doesn't support the ISO style locale namings, even though
the setlocale() page says The set of available languages, country/region 
codes, and code pages
includes all those supported by the Win32 NLS API and the Win32
API does support the ISO names:

http://msdn.microsoft.com/en-us/library/dd373814(VS.85).aspx

I'll have to check whether Vista also shows this behavior. On
Win XP the setlocale() API doesn't accept ISO language names;
I can confirm that. It only accepts the fully written out
form described on the above pages.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-23 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg m...@egenix.com added the comment:
 
 R. David Murray wrote:

 R. David Murray rdmur...@bitdance.com added the comment:

 I had a report from a user on IRC during the bug weekend that they could not 
 reproduce the failure on windows.  So it may be dependent on the windows 
 version.  That doesn't answer your question of why it hasn't come up before, 
 though, since my tests were done on XP.
 
 Some research shows that the MS VCRT uses non-ISO locale names
 for setlocale():
 
 http://msdn.microsoft.com/en-us/library/x99tb11d.aspx
 http://msdn.microsoft.com/en-us/library/hzz3tw78.aspx
 http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx
 http://msdn.microsoft.com/en-us/library/cdax410z.aspx
 
 and it doesn't support the ISO style locale namings, even though
 the setlocale() page says The set of available languages, country/region 
 codes, and code pages
 includes all those supported by the Win32 NLS API and the Win32
 API does support the ISO names:
 
 http://msdn.microsoft.com/en-us/library/dd373814(VS.85).aspx
 
 I'll have to check whether Vista also shows this behavior. On
 Win XP the setlocale() API doesn't accept ISO language names;
 I can confirm that. It only accepts the fully written out
 form described on the above pages.

Confirmed on Vista as well.

I think the only choice we have is to add a new alias dictionary
mapping the ISO language names to the Windows ones.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-22 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

I think that's a bug in the resetlocale() API.

The correct way to reset the locale setting to defaults, it to use

setlocale(category, )

The other issues here is that getlocale() appears to return non-ISO language 
codes on Windows. If that's indeed the case, then we would need to add mappings 
of the Windows codes to the ISO ones and use a reverse mappings to make 
setlocale() work with the ISO codes.

Perhaps it's easier to just update the mapping used by getdefaultencoding() to 
return the non-ISO codes used by Windows and then update the documentation to 
say that on Windows, non-ISO codes are returned.

BTW: I wonder why this hasn't popped up earlier.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I had a report from a user on IRC during the bug weekend that they could not 
reproduce the failure on windows.  So it may be dependent on the windows 
version.  That doesn't answer your question of why it hasn't come up before, 
though, since my tests were done on XP.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-21 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

It is unfunny that your program fails on Windows.

Yes it is the same bug, since calendar calls getdefaultlocale.

Issue 1080864 makes very interesting reading in this context.  Clearly Martin 
is right, yet the OP seems to find the current behavior of getdefaultencoding 
(returning the more standard locale name rather than Windows unique values) 
useful.

It is an interesting question what can be done about this.  Clearly resetlocale 
is non-functional on Windows, and getdefaultlocale is of questionable utility.  
At the very least these limitations need to be documented.

Your application bug, however, can probably be addressed by fixing calendar to 
not use getdefaultencoding.  We should open a new bug for that, though.

--
nosy: +loewis
title: locale.py resetlocale throws exception on Windows - locale.py 
resetlocale throws exception on Windows (getdefaultlocale returns value not 
usable in setlocale)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-21 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I've opened issue 10498 for the calendar bug.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2010-11-21 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

FYI, calendar.localeHTMLCalendar() fails on OS X in exactly the same way for 
exactly the same reason.  See, for instance, Issue10090.

--
nosy: +ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com