bpo-30410: Documentation of sys.stdin/out/err update to reflect chang… · python/cpython@b8bcec3 (original) (raw)

`@@ -1348,13 +1348,30 @@ always available.

`

1348

1348

`` returned by the :func:open function. Their parameters are chosen as

``

1349

1349

` follows:

`

1350

1350

``

1351

``

`-

`

1352

``


 is interactive (that is, if its :meth:`isatty` method returns ``True``), the

1353

``

`-

console codepage is used, otherwise the ANSI code page. Under other

`

1354

``

`` -

platforms, the locale encoding is used (see :meth:locale.getpreferredencoding).

``

1355

``

-

1356

``

`-

Under all platforms though, you can override this value by setting the

`

1357

``

`` -

:envvar:PYTHONIOENCODING environment variable before starting Python.

``

``

1351

`+

`

``

1352

`+

platforms use the locale encoding (see

`

``

1353

`` +

:meth:locale.getpreferredencoding()).

``

``

1354

+

``

1355

`+

On Windows, UTF-8 is used for the console device. Non-character

`

``

1356

`+

devices such as disk files and pipes use the system locale

`

``

1357

`+

encoding (i.e. the ANSI codepage). Non-console character

`

``

1358

`+

devices such as NUL (i.e. where isatty() returns True) use the

`

``

1359

`+

value of the console input and output codepages at startup,

`

``

1360

`+

respectively for stdin and stdout/stderr. This defaults to the

`

``

1361

`+

system locale encoding if the process is not initially attached

`

``

1362

`+

to a console.

`

``

1363

+

``

1364

`+

The special behaviour of the console can be overridden

`

``

1365

`+

by setting the environment variable PYTHONLEGACYWINDOWSSTDIO

`

``

1366

`+

before starting Python. In that case, the console codepages are

`

``

1367

`+

used as for any other character device.

`

``

1368

+

``

1369

`+

Under all platforms, you can override the character encoding by

`

``

1370

`` +

setting the :envvar:PYTHONIOENCODING environment variable before

``

``

1371


 starting Python or by using the new :option:`-X` ``utf8`` command

``

1372

`` +

line option and :envvar:PYTHONUTF8 environment variable. However,

``

``

1373

`+

for the Windows console, this only applies when

`

``

1374

`` +

:envvar:PYTHONLEGACYWINDOWSSTDIO is also set.

``

1358

1375

``

1359

1376

``` * When interactive, stdout and stderr streams are line-buffered.

```

1360

1377

` Otherwise, they are block-buffered like regular text files. You can

`