[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.
STINNER Victor
report at bugs.python.org
Tue Mar 22 09:18:22 EDT 2022
STINNER Victor <vstinner at python.org> added the comment:
> But some user want to use UTF-8 mode to change default encoding in their Python environments without waiting Python default encoding changed.
IMO it's a different use case and it should be a different thing. Changing encoding="locale" today is too late, since it's already shipped in Python 3.10 (PEP 597).
I proposed the "current locale" name to distinguish it from the existing "locale":
* "current locale": LC_CTYPE locale encoding or ANSI code page
* "locale": "UTF-8" in UTF-8 Mode, or the current locale
The unclear part to me is if "current locale" must change if the LC_CTYPE locale is changed, or if it should be read once at startup and then never change.
There *are* use case to really read the *current* LC_CTYPE locale encoding. There is already C API for that:
* PyUnicode_EncodeLocale()
* PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize()
See also the "current_locale" parameter of the private API _Py_EncodeLocaleEx() and _Py_DecodeLocaleEx().
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47000>
_______________________________________
More information about the Python-bugs-list
mailing list