Message412647
The locale.getdefaultlocale() function only relies on environment variables. At Python startup, Python calls setlocale() is set the LC_CTYPE locale to the user preferred encoding.
Since Python 3.7, if the LC_CTYPE locale is "C" or "POSIX", PEP 538 sets the LC_CTYPE locale to a UTF-8 variant if available, and PEP 540 ignores the locale and forces the usage of the UTF-8 encoding. The *effective* encoding used by Python is inconsistent with environment variables.
Moreover, if setlocale() is called to set the LC_CTYPE locale to a locale different than the user locale, again, environment variables are inconsistent with the effective locale.
In these cases, locale.getdefaultlocale() result is not the expected locale and it can lead to mojibake and other issues.
For these reasons, I propose to deprecate locale.getdefaultlocale(): setlocale(), getpreferredencoding() and getlocale() should be used instead.
For the background on these issues, see recent issue:
* bpo-43552
* bpo-43557 |
|
Date |
User |
Action |
Args |
2022-02-06 17:33:14 | vstinner | set | recipients:
+ vstinner |
2022-02-06 17:33:14 | vstinner | set | messageid: <1644168794.44.0.0658923518102.issue46659@roundup.psfhosted.org> |
2022-02-06 17:33:14 | vstinner | link | issue46659 messages |
2022-02-06 17:33:14 | vstinner | create | |
|