[issue42707] Python uses ANSI CP for stdio on Windows console instead of using console or OEM CP

Eryk Sun report at bugs.python.org
Tue Dec 22 21:50:45 EST 2020


Eryk Sun <eryksun at gmail.com> added the comment:

> When there is no console, stdio should use the default textio 
> encoding that is ANSI for now.

stdin, stdout, and stderr are special and can be special cased because they're used implicitly for IPC. They've always been acknowledged as special by the existence of PYTHONIOENCODING. I think if Python is going to change its policy for standard I/O, along the lines of what I think you've been arguing in favor of for months now, it should commit to (almost) consistently using the console input and output code pages for the standard I/O encoding in Windows, with UTF-8 as the default when there is no console session, and with the exception that UTF-8 is used for console files. To get legacy behavior, set PYTHONLEGACYWINDOWSSTDIO, which will use the console code pages for console standard I/O and otherwise use the process active code page for standard I/O.

The default encoding for open() would still be the process active code page from GetACP(), and the recommendation should be for scripts to use an explicit `encoding`.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42707>
_______________________________________


More information about the Python-bugs-list mailing list