[issue43115] locale.getlocale fails if locale is set

2021-02-23 Thread Eryk Sun
Eryk Sun added the comment: > All getlocale is used for in _strptime.py is comparing the value > returned to the previous value returned. Which is why _strptime should be calling setlocale(LC_TIME), the same as the calendar module. That's not to say that I don't think getlocale() and

[issue43115] locale.getlocale fails if locale is set

2021-02-23 Thread Anders Munch
Anders Munch added the comment: >> What does use getlocale is time.strptime and datetime.datetime.strptime, so >> when getlocale fails, strptime fails. > Would they work with getlocale() returning None for the encoding ? Yes. All getlocale is used for in _strptime.py is comparing the value

[issue43115] locale.getlocale fails if locale is set

2021-02-18 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 18.02.2021 19:04, Eryk Sun wrote: > > Eryk Sun added the comment: > >> The APIs were written at a time where locale modifiers >> simply did mot exist. > > Technically, locale modifiers did exist circa 2000, but I suppose you mean > that they were

[issue43115] locale.getlocale fails if locale is set

2021-02-18 Thread Eryk Sun
Eryk Sun added the comment: > The APIs were written at a time where locale modifiers > simply did mot exist. Technically, locale modifiers did exist circa 2000, but I suppose you mean that they were uncommon to the point of being unheard of at the time. The modifier field was specified in

Re: [issue43115] locale.getlocale fails if locale is set

2021-02-18 Thread M.-A. Lemburg
On 17.02.2021 15:02, Anders Munch wrote: >> BTW: What is wxWidgets doing with the returned values ? > > wxWidgets doesn't call getlocale, it's a C++ library (wrapped by wxPython) > that uses C setlocale. > > What does use getlocale is time.strptime and datetime.datetime.strptime, so > when

[issue43115] locale.getlocale fails if locale is set

2021-02-18 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 18.02.2021 10:36, Eryk Sun wrote: > It's not just a Windows problem. For example, getlocale() doesn't return the > POSIX locale modifier in a 3-tuple (language, encoding, modifier). So it > can't be used to restore a locale for which the modifier is

[issue43115] locale.getlocale fails if locale is set

2021-02-18 Thread Eryk Sun
Eryk Sun added the comment: > Is this the same as the other issue where get_locale is normalising > the result according to some particular glibc logic and isn't at > all portable? If I understand Anders' immediate problem correctly, I think it can be addressed by using setlocale() to save

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Steve Dower
Steve Dower added the comment: Is this the same as the other issue where get_locale is normalising the result according to some particular glibc logic and isn't at all portable? -- ___ Python tracker

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Eryk Sun
Eryk Sun added the comment: > What does use getlocale is time.strptime and datetime.datetime.strptime calendar.LocaleTextCalendar also uses getlocale() and getdefaultlocale(). The result from getdefaultlocale() cannot be set via setlocale() in Windows, which also breaks resetlocale().

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: > BTW: What is wxWidgets doing with the returned values ? wxWidgets doesn't call getlocale, it's a C++ library (wrapped by wxPython) that uses C setlocale. What does use getlocale is time.strptime and datetime.datetime.strptime, so when getlocale fails,

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 17.02.2021 12:36, Anders Munch wrote: > getlocale is documented to return None for the encoding if no encoding can be > determined. There's no need to guess. Well, not quite... the documentation says that None can be returned, not that it will return

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: getlocale is documented to return None for the encoding if no encoding can be determined. There's no need to guess. I can't change the locale.setlocale call, because where I'm actually having the problem, I'm not even calling locale.setlocale: wxWidgets is

Re: [issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread M.-A. Lemburg
On 17.02.2021 10:55, Anders Munch wrote: import locale locale.setlocale(locale.LC_ALL, 'en_DE') > 'en_DE' locale.getlocale() > Traceback (most recent call last): > File "", line 1, in > File "C:\flonidan\env\Python38-64\lib\locale.py", line 591, in getlocale > return

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: I discovered that this can happen with underscores as well: Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>>

[issue43115] locale.getlocale fails if locale is set

2021-02-03 Thread Scott Talbert
Change by Scott Talbert : -- nosy: +swt2c ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43115] locale.getlocale fails if locale is set

2021-02-03 Thread Anders Munch
New submission from Anders Munch : getlocale fails with an exception when the string returned by _setlocale is already an RFC 1766 language tag. Example: Python 3.10.0a4 (tags/v3.10.0a4:445f7f5, Jan 4 2021, 19:55:53) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits"