diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-03-27 18:28:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-27 18:28:46 +0100 |
commit | d929f1838a8fba881ff0148b7fc31f6265703e3d (patch) | |
tree | 36ff97834b250c4412d5a95c2206c8ba9d5cf13e /Lib/test/test_embed.py | |
parent | 4a9a505d6f2474a570422dad89f8d1b344d6cd36 (diff) | |
download | cpython-git-d929f1838a8fba881ff0148b7fc31f6265703e3d.tar.gz |
bpo-36443: Disable C locale coercion and UTF-8 Mode by default (GH-12589)
bpo-36443, bpo-36202: Since Python 3.7.0, calling Py_DecodeLocale()
before Py_Initialize() produces mojibake if the LC_CTYPE locale is
coerced and/or if the UTF-8 Mode is enabled by the user
configuration. This change fix the issue by disabling LC_CTYPE
coercion and UTF-8 Mode by default. They must now be enabled
explicitly (opt-in) using the new _Py_PreInitialize() API with
_PyPreConfig.
When embedding Python, set coerce_c_locale and utf8_mode attributes
of _PyPreConfig to -1 to enable automatically these parameters
depending on the LC_CTYPE locale, environment variables and command
line arguments
Alternative: Setting Py_UTF8Mode to 1 always explicitly enables the
UTF-8 Mode.
Changes:
* _PyPreConfig_INIT now sets coerce_c_locale and utf8_mode to 0 by
default.
* _Py_InitializeFromArgs() and _Py_InitializeFromWideArgs() can now
be called with config=NULL.
Diffstat (limited to 'Lib/test/test_embed.py')
-rw-r--r-- | Lib/test/test_embed.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index c63ea5a45e..164527a664 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -494,8 +494,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): if key not in expected_preconfig: expected_preconfig[key] = expected_config[key] - self.check_core_config(config, expected_config) self.check_pre_config(config, expected_preconfig) + self.check_core_config(config, expected_config) self.check_global_config(config) def test_init_default_config(self): @@ -573,7 +573,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): INIT_ENV_PRECONFIG = { 'allocator': 'malloc', - 'utf8_mode': 1, } INIT_ENV_CONFIG = { 'use_hash_seed': 1, @@ -581,8 +580,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'tracemalloc': 2, 'import_time': 1, 'malloc_stats': 1, - 'filesystem_encoding': 'utf-8', - 'filesystem_errors': UTF8_MODE_ERRORS, 'inspect': 1, 'optimization_level': 2, 'pycache_prefix': 'env_pycache_prefix', |