[Python-checkins] bpo-30410: Documentation of sys.stdin/out/err update to reflect change in 3.6 (GH-10264)
Miss Islington (bot)
webhook-mailer at python.org
Thu Feb 14 18:45:24 EST 2019
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
bpo-30410: Documentation of sys.stdin/out/err update to reflect change in 3.6 (GH-10264)
Documentation of sys.stdin/out/err update to reflect change in 3.6 on Windows to use UTF-8.
Wording by Eryk Sun and Paul Moore.
(cherry picked from commit 5723263a3a39a05b6a2f567e0e7771792e6e2f5b)
Co-authored-by: Lysandros Nikolaou <lisandrosnik at gmail.com>
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 63861abb431a..ace0e2808b18 100644
@@ -1348,13 +1348,30 @@ always available.
returned by the :func:`open` function. Their parameters are chosen as
- * The character encoding is platform-dependent. Under Windows, if the stream
- is interactive (that is, if its :meth:`isatty` method returns ``True``), the
- console codepage is used, otherwise the ANSI code page. Under other
- platforms, the locale encoding is used (see :meth:`locale.getpreferredencoding`).
- Under all platforms though, you can override this value by setting the
- :envvar:`PYTHONIOENCODING` environment variable before starting Python.
+ * The character encoding is platform-dependent. Non-Windows
+ platforms use the locale encoding (see
+ On Windows, UTF-8 is used for the console device. Non-character
+ devices such as disk files and pipes use the system locale
+ encoding (i.e. the ANSI codepage). Non-console character
+ devices such as NUL (i.e. where 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.
+ The special behaviour of the console can be overridden
+ by setting the environment variable PYTHONLEGACYWINDOWSSTDIO
+ before starting Python. In that case, the console codepages are
+ used as for any other character device.
+ Under all platforms, you can override the character encoding by
+ setting the :envvar:`PYTHONIOENCODING` environment variable before
+ starting Python or by using the new :option:`-X` ``utf8`` command
+ line option and :envvar:`PYTHONUTF8` environment variable. However,
+ for the Windows console, this only applies when
+ :envvar:`PYTHONLEGACYWINDOWSSTDIO` is also set.
* When interactive, ``stdout`` and ``stderr`` streams are line-buffered.
Otherwise, they are block-buffered like regular text files. You can
More information about the Python-checkins