[docs] [issue30410] Documentation for sys.stdout encoding does not reflect the new Windows behavior in Python 3.6+

Eryk Sun report at bugs.python.org
Sat May 20 14:37:01 EDT 2017


Eryk Sun added the comment:

How about this?

    The character encoding is platform-dependent. Non-Windows 
    platforms use the locale encoding (see 
    locale.getpreferredencoding()).

    On Windows, UTF-8 is used for console character 
    devices (i.e. CON, CONIN$, and CONOUT$). However, this
    can be overridden to use the console as a generic 
    character device by setting the environment variable 
    PYTHONLEGACYWINDOWSSTDIO before starting Python. Non-
    character devices such as disk files and pipes use the 
    system locale encoding (i.e. the ANSI codepage). 
    Character devices such as NUL (i.e. isatty() returns 
    True) use the value of the console input and output
    codepages at startup, respectively for stdin and
    stdout/stderr. This defaults to the system locale
    encoding if the process is not initially attached to a
    console.

    Under all platforms, you can override this value by
    setting the PYTHONIOENCODING environment variable before
    starting Python. However, for the Windows console, this
    only applies when PYTHONLEGACYWINDOWSSTDIO is also set.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30410>
_______________________________________


More information about the docs mailing list