PEP 540: Fix effects of the PEP 538

This commit is contained in:
Victor Stinner 2017-12-10 18:18:26 +01:00
parent b65d0681d4
commit 71cda51fbb
1 changed files with 9 additions and 3 deletions

View File

@ -144,9 +144,15 @@ The POSIX locale enables the locale coercion (PEP 538) and the UTF-8
mode (PEP 540). When the locale coercion is enabled, enabling the UTF-8
mode has no (additional) effect.
Locale coercion only impacts non-Python code like C libraries, whereas
the Python UTF-8 Mode only impacts Python code: the two PEPs are
complementary.
The UTF-8 has the same effect than locale coercion:
``sys.getfilesystemencoding()`` returns ``'UTF-8'``,
``locale.getpreferredencoding()`` returns ``UTF-8``, ``sys.stdin`` and
``sys.stdout`` error handler set to ``surrogateescape``. These changes
only affect Python code. But the locale coercion has addiditonal
effects: the ``LC_CTYPE`` environment variable and the ``LC_CTYPE``
locale are set to a UTF-8 locale like ``C.UTF-8``. The side effect is
that non-Python code is also impacted by the locale coercion. The two
PEPs are complementary.
On platforms where locale coercion is not supported like Centos 7, the
POSIX locale only enables the UTF-8 Mode. In this case, Python code uses