PEP 538: clarify sys.stderr error handler isn't changing
The previous wording suggested that all three standard streams were affected by the proposed change to the default error handler. Only stdin and stdout are affected - the default error handler for stderr continues to be "backslashreplace"
This commit is contained in:
parent
2fb53e7c1b
commit
4067701b85
24
pep-0538.txt
24
pep-0538.txt
|
@ -49,9 +49,9 @@ changed such that:
|
|||
locale to the first available locale out of ``C.UTF-8``, ``C.utf8``, or
|
||||
``UTF-8``
|
||||
* ``Py_Initialize`` will be updated to treat these potential coercion target
|
||||
locales the same way it already treats the ``C`` locale: the default standard
|
||||
stream error handler for these locales will become ``surrogateescape`` (this
|
||||
default can be overridden through ``PYTHONIOENCODING`` and
|
||||
locales the same way it already treats the ``C`` locale: the default ``stdin``
|
||||
& ``stdout`` error handler for these locales will become ``surrogateescape``
|
||||
(this default can be overridden through ``PYTHONIOENCODING`` and
|
||||
``Py_SetStandardStreamEncoding`` as usual)
|
||||
* if ``Py_Initialize`` detects that the legacy ``C`` locale remains active
|
||||
(e.g. none of ``C.UTF-8``, ``C.utf8`` or ``UTF-8``
|
||||
|
@ -508,9 +508,9 @@ Changes to the default error handling on the standard streams
|
|||
-------------------------------------------------------------
|
||||
|
||||
Since Python 3.5, CPython has defaulted to using ``surrogateescape`` on the
|
||||
standard streams (``sys.stdin``, ``sys.stdout``, ``sys.stderr``) when it
|
||||
detects that the current locale is ``C`` and no specific error handled has
|
||||
been set using either the ``PYTHONIOENCODING`` environment variable or the
|
||||
standard streams (``sys.stdin``, ``sys.stdout``) when it detects that the
|
||||
current locale is ``C`` and no specific error handled has been set using
|
||||
either the ``PYTHONIOENCODING`` environment variable or the
|
||||
``Py_setStandardStreamEncoding`` API. For other locales, the default error
|
||||
handler for the standard streams is ``strict``.
|
||||
|
||||
|
@ -520,6 +520,9 @@ coercion target locales (``C.UTF-8``, ``C.utf8``, and ``UTF-8``) will be added
|
|||
to the list of locales that use ``surrogateescape`` as their default error
|
||||
handler for the standard streams.
|
||||
|
||||
No changes are proposed to the default error handler for ``sys.stderr``: that
|
||||
will continue to be ``backslashreplace``.
|
||||
|
||||
|
||||
Changes to locale settings on Android
|
||||
-------------------------------------
|
||||
|
@ -597,11 +600,12 @@ By coercing the locale away from the legacy C default and its assumption of
|
|||
ASCII as the preferred text encoding, this PEP also disables the implicit use
|
||||
of the "surrogateescape" error handler on the standard IO streams that was
|
||||
introduced in Python 3.5 ([15_]), as well as the automatic use of
|
||||
``surrogateescape`` when operating in PEP 540's UTF-8 mode.
|
||||
``surrogateescape`` when operating in PEP 540's proposed UTF-8 mode.
|
||||
|
||||
Rather than introducing yet another configuration option to address that,
|
||||
this PEP proposes to extend the "surrogateescape" default to also apply to
|
||||
the three potential coercion target locales.
|
||||
Rather than introducing yet another configuration option to adjust that
|
||||
behaviour, this PEP instead proposes to extend the "surrogateescape" default
|
||||
for ``stdin`` and ``stderr`` error handling to also apply to the three
|
||||
potential coercion target locales.
|
||||
|
||||
The aim of this behaviour is to attempt to ensure that operating system
|
||||
provided text values are typically able to be transparently passed through a
|
||||
|
|
Loading…
Reference in New Issue