Message 389091 - Python tracker (original) (raw)

Is it about the current implementation of the PEP 597, or are you thinking at the future Python which would use UTF-8 by default?

I had forgot to consider about UTF-8 mode while finishing PEP 597. If possible, I want to ignore UTF-8 mode when encoding="locale" is specified from Python 3.10. Otherwise, behavior will be changed between Python 3.10 and 3.11.

Currently, getpreferredencoding(False) respects the behavior that you described, no?

getpreferredencoding(False) respects UTF-8 mode. That's what PEP 597 said (because the PEP don't define behavior in UTF-8 mode) and GH-19481 implements.

But it is not what I want for now. I want to ignore UTF-8 mode when encoding="locale" is specified.

This is almost "only in Windows" issue, and users can use encoding="mbcs" in Windows-only script.

But encoding="locale" is new and recommended way to specify using "locale" encoding explicitly. When user specify "locale" encoding explicitly, I think we should respect it regardless UTF-8 mode.