Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5723263

Browse files
lysnikolaoumiss-islington
authored andcommitted
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. https://bugs.python.org/issue30410
1 parent 1093d42 commit 5723263

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

Doc/library/sys.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,13 +1368,30 @@ always available.
13681368
returned by the :func:`open` function. Their parameters are chosen as
13691369
follows:
13701370

1371-
* The character encoding is platform-dependent. Under Windows, if the stream
1372-
is interactive (that is, if its :meth:`isatty` method returns ``True``), the
1373-
console codepage is used, otherwise the ANSI code page. Under other
1374-
platforms, the locale encoding is used (see :meth:`locale.getpreferredencoding`).
1375-
1376-
Under all platforms though, you can override this value by setting the
1377-
:envvar:`PYTHONIOENCODING` environment variable before starting Python.
1371+
* The character encoding is platform-dependent. Non-Windows
1372+
platforms use the locale encoding (see
1373+
:meth:`locale.getpreferredencoding()`).
1374+
1375+
On Windows, UTF-8 is used for the console device. Non-character
1376+
devices such as disk files and pipes use the system locale
1377+
encoding (i.e. the ANSI codepage). Non-console character
1378+
devices such as NUL (i.e. where isatty() returns True) use the
1379+
value of the console input and output codepages at startup,
1380+
respectively for stdin and stdout/stderr. This defaults to the
1381+
system locale encoding if the process is not initially attached
1382+
to a console.
1383+
1384+
The special behaviour of the console can be overridden
1385+
by setting the environment variable PYTHONLEGACYWINDOWSSTDIO
1386+
before starting Python. In that case, the console codepages are
1387+
used as for any other character device.
1388+
1389+
Under all platforms, you can override the character encoding by
1390+
setting the :envvar:`PYTHONIOENCODING` environment variable before
1391+
starting Python or by using the new :option:`-X` ``utf8`` command
1392+
line option and :envvar:`PYTHONUTF8` environment variable. However,
1393+
for the Windows console, this only applies when
1394+
:envvar:`PYTHONLEGACYWINDOWSSTDIO` is also set.
13781395

13791396
* When interactive, ``stdout`` and ``stderr`` streams are line-buffered.
13801397
Otherwise, they are block-buffered like regular text files. You can

0 commit comments

Comments
 (0)