]> granicus.if.org Git - python/commit
bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 13 Dec 2017 11:29:09 +0000 (12:29 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Dec 2017 11:29:09 +0000 (12:29 +0100)
commit91106cd9ff2f321c0f60fbaa09fd46c80aa5c266
treeff002e0532736a97f3ddd367c1491e7b04611816
parentc3e070f84931c847d1b35e7fb36aa71edd6215f6
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.
27 files changed:
Doc/c-api/sys.rst
Doc/library/locale.rst
Doc/library/sys.rst
Doc/using/cmdline.rst
Doc/whatsnew/3.7.rst
Include/fileobject.h
Include/pystate.h
Lib/_bootlocale.py
Lib/encodings/__init__.py
Lib/locale.py
Lib/subprocess.py
Lib/test/test_builtin.py
Lib/test/test_c_locale_coercion.py
Lib/test/test_codecs.py
Lib/test/test_io.py
Lib/test/test_sys.py
Lib/test/test_utf8_mode.py [new file with mode: 0644]
Misc/NEWS.d/next/Core and Builtins/2017-12-05-23-10-58.bpo-29240.qpJP5l.rst [new file with mode: 0644]
Modules/_winapi.c
Modules/clinic/_winapi.c.h
Modules/main.c
Objects/unicodeobject.c
Programs/python.c
Python/bltinmodule.c
Python/fileutils.c
Python/pylifecycle.c
Python/sysmodule.c