[3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion off by default (GH-9379)
* bpo-34589: Make _PyCoreConfig.coerce_c_locale private (GH-9371)
_PyCoreConfig:
* Rename coerce_c_locale to _coerce_c_locale
* Rename coerce_c_locale_warn to _coerce_c_locale_warn
These fields are now private (name prefixed by "_").
(cherry picked from commit 188ebfa475a6f6aa2d0ea14ca8e1fbe7865b6d27)
* bpo-34589: C locale coercion off by default (GH-9073)
Py_Initialize() and Py_Main() cannot enable the C locale coercion
(PEP 538) anymore: it is always disabled. It can now only be enabled
by the Python program ("python3).
test_embed: get_filesystem_encoding() doesn't have to set PYTHONUTF8
nor PYTHONCOERCECLOCALE, these variables are already set in the
parent.
(cherry picked from commit 7a0791b6992d420dc52536257f2f093851ed7215)
* bpo-34589: Add -X coerce_c_locale command line option (GH-9378)
Add a new -X coerce_c_locale command line option to control C locale
coercion (PEP 538).
(cherry picked from commit dbdee0073cf0b88fe541980ace1f650900f455cc)
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 27f7590..9155afc 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -656,9 +656,8 @@
def c_locale_get_error_handler(self, locale, isolated=False, encoding=None):
# Force the POSIX locale
- env = os.environ.copy()
+ env = dict(os.environ)
env["LC_ALL"] = locale
- env["PYTHONCOERCECLOCALE"] = "0"
code = '\n'.join((
'import sys',
'def dump(name):',
@@ -668,7 +667,10 @@
'dump("stdout")',
'dump("stderr")',
))
- args = [sys.executable, "-c", code]
+ args = [sys.executable,
+ "-X", "utf8=0",
+ "-X", "coerce_c_locale=0",
+ "-c", code]
if isolated:
args.append("-I")
if encoding is not None: