[issue43115] locale.getlocale fails if locale is set

Anders Munch report at bugs.python.org
Wed Feb 17 09:02:57 EST 2021


Anders Munch <anders at jmunch.dk> 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, strptime fails.

> We could enhance this to return None for the encoding instead
> of raising an exception, but would this really help ?

Very much so.

Frankly, I don't get the impression that the current locale preferred encoding is used for *anything*.  Other than possibly having a role in implementing getpreferredencoding.

> Alternatively, we could add "en_DE" to the alias table and set
> a default encoding to use. 

Where would you get a complete list of all the new aliases that would need be to be added?

As the "en_DE" example shows, you'd need all combinations of languages and regions.  That's going to be a very long list.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43115>
_______________________________________


More information about the Python-bugs-list mailing list