Message389070
> Martin later added locale.getpreferredencoding(), which tries to
> determine the encoding in a different way new way, based on
> nl_langset(CODEINFO). As you mentioned, this intention was broken
> on several platforms by forcing UTF-8 as output.
When I designed and implemented the PEP 540 (Python UTF-8 Mode), I tried to leave getpreferredencoding() unchanged. The problem was that I quickly got mojibake because too many functions call getpreferredencoding(False):
* open() and _pyio.open() -- in Python 3.10, open() now calls the C _Py_GetLocaleEncoding() function to fix issues during Python shutdown, it also avoids issues at startup.
* Many gettext functions
* cgi to decode the query string from QUERY_STRING env var or sys.argv[1]}
* xml.etree.ElementTree.write(encoding="unicode") is some cases
The Python UTF-8 Mode ignores the locale *on purpose*. But I agree that it's surprising and can lead to confusion. That's what I'm trying to fix here :-) |
|
Date |
User |
Action |
Args |
2021-03-19 11:11:34 | vstinner | set | recipients:
+ vstinner, lemburg |
2021-03-19 11:11:34 | vstinner | set | messageid: <1616152294.5.0.168060102826.issue43552@roundup.psfhosted.org> |
2021-03-19 11:11:34 | vstinner | link | issue43552 messages |
2021-03-19 11:11:34 | vstinner | create | |
|