summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-13 11:29:09 (GMT)
committerGitHub <noreply@github.com>2017-12-13 11:29:09 (GMT)
commit91106cd9ff2f321c0f60fbaa09fd46c80aa5c266 (patch)
treeff002e0532736a97f3ddd367c1491e7b04611816 /Doc/c-api
parentc3e070f84931c847d1b35e7fb36aa71edd6215f6 (diff)
downloadcpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.zip
cpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.tar.gz
cpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.tar.bz2
bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)
* Add -X utf8 command line option, PYTHONUTF8 environment variable and a new sys.flags.utf8_mode flag. * If the LC_CTYPE locale is "C" at startup: enable automatically the UTF-8 mode. * Add _winapi.GetACP(). encodings._alias_mbcs() now calls _winapi.GetACP() to get the ANSI code page * locale.getpreferredencoding() now returns 'UTF-8' in the UTF-8 mode. As a side effect, open() now uses the UTF-8 encoding by default in this mode. * Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding in the UTF-8 Mode. * Update subprocess._args_from_interpreter_flags() to handle -X utf8 * Skip some tests relying on the current locale if the UTF-8 mode is enabled. * Add test_utf8mode.py. * _Py_DecodeUTF8_surrogateescape() gets a new optional parameter to return also the length (number of wide characters). * pymain_get_global_config() and pymain_set_global_config() now always copy flag values, rather than only copying if the new value is greater than the old value.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/sys.rst13
1 files changed, 11 insertions, 2 deletions
diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst
index 95d9d65..20bc7bd 100644
--- a/Doc/c-api/sys.rst
+++ b/Doc/c-api/sys.rst
@@ -127,6 +127,9 @@ Operating System Utilities
.. versionadded:: 3.5
+ .. versionchanged:: 3.7
+ The function now uses the UTF-8 encoding in the UTF-8 mode.
+
.. c:function:: char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
@@ -138,12 +141,15 @@ Operating System Utilities
to free the memory. Return ``NULL`` on encoding error or memory allocation
error
- If error_pos is not ``NULL``, ``*error_pos`` is set to the index of the
- invalid character on encoding error, or set to ``(size_t)-1`` otherwise.
+ If error_pos is not ``NULL``, ``*error_pos`` is set to ``(size_t)-1`` on
+ success, or set to the index of the invalid character on encoding error.
Use the :c:func:`Py_DecodeLocale` function to decode the bytes string back
to a wide character string.
+ .. versionchanged:: 3.7
+ The function now uses the UTF-8 encoding in the UTF-8 mode.
+
.. seealso::
The :c:func:`PyUnicode_EncodeFSDefault` and
@@ -151,6 +157,9 @@ Operating System Utilities
.. versionadded:: 3.5
+ .. versionchanged:: 3.7
+ The function now supports the UTF-8 mode.
+
.. _systemfunctions: