Anders Munch added the comment:
Are you sure you want to do this?
This optimisation is not applicable if the matched values are given symbolic
names. You would be encouraging people to write bad code with lots of
literals, for speed.
--
nosy: +AndersMunch
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 comp
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 ge
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.set
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"
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", "copyr