This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients lemburg, vstinner
Date 2021-03-19.10:36:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> locale.getencoding()
> which interfaces to nl_langinfo(CODESET) or the Windows code
> page and does not try to do any magic, ie. does *not* call
> setlocale(). It needs to return what the lib C currently
> knows and uses as encoding.

This is locale.get_current_locale_encoding(). I would like to put "current" in the name, because there is a lot of confusion between get_current_locale_encoding() encoding and locale.getpreferredencoding(False) encoding. In locale.getpreferredencoding(False), Python ignores the locale in some cases which is counter intuitive.

I propose to add new functions to reduce confusion and better document the subtle differences between the different "locale encodings".

That's also why I propose to rename the "locale encoding" to the "Python locale encoding" in the documentation: clarify the Python ignores the locale sometimes.

The PEP 538 (coerce the C locale) and PEP 540 (Python UTF-8 Mode) introduced confusion.
Date User Action Args
2021-03-19 10:36:11vstinnersetrecipients: + vstinner, lemburg
2021-03-19 10:36:11vstinnersetmessageid: <>
2021-03-19 10:36:11vstinnerlinkissue43552 messages
2021-03-19 10:36:11vstinnercreate