Author lemburg
Recipients AndersMunch, eryksun, lemburg, paul.moore, steve.dower, swt2c, tim.golden, zach.ware
Date 2021-02-18.10:16:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <cc1dcfe1-2956-6d5a-44cc-66333ce25da5@egenix.com>
In-reply-to <1613570577.83.0.979105361569.issue43115@roundup.psfhosted.org>
Content
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 getlocale fails, strptime fails.

Would they work with getlocale() returning None for the encoding ?

>> 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.

The logic for getdefaultencoding() predates getpreferredencoding().
I had added it because calling setlocale() just to figure out the default
encoding and then resetting it to the original setting is dangerous
in a multi-threaded application such as a web server -- setlocale()
changes the locale for the entire process.

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

We could start with the list of supported locales in Windows:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-160

Since everything is moving toward UTF-8 as standard encoding,
I'd suggest use alias the plain locale codes to <locale>.UTF-8.
History
Date User Action Args
2021-02-18 10:16:46lemburgsetrecipients: + lemburg, paul.moore, tim.golden, zach.ware, eryksun, steve.dower, swt2c, AndersMunch
2021-02-18 10:16:46lemburglinkissue43115 messages
2021-02-18 10:16:45lemburgcreate