summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-28 23:13:29 (GMT)
committerGitHub <noreply@github.com>2018-08-28 23:13:29 (GMT)
commit98c49c6ab239875e35a3c271bc8fabde6c9be804 (patch)
tree4d3a7017dd1582e344ca478d5b769dfc7a647090 /Python/pylifecycle.c
parent65ef7425a32ee411d8047a4fad0fc6bb9ff733b1 (diff)
downloadcpython-98c49c6ab239875e35a3c271bc8fabde6c9be804.zip
cpython-98c49c6ab239875e35a3c271bc8fabde6c9be804.tar.gz
cpython-98c49c6ab239875e35a3c271bc8fabde6c9be804.tar.bz2
bpo-34485: Fix _Py_InitializeCore() for C locale coercion (GH-8979) (GH-8981)
* _Py_InitializeCore() now sets the LC_CTYPE locale to the user preferred locale before checking if the C locale should be coerced or not in _PyCoreConfig_Read(). * Fix pymain_read_conf(): remember if the C locale has been coerced when the configuration should be read again if the encoding has changed. (cherry picked from commit 2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab)
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index f75b860..fc4ee06 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -672,10 +672,6 @@ _Py_InitializeCore_impl(PyInterpreterState **interp_p,
_PyRuntime.finalizing = NULL;
#ifndef MS_WINDOWS
- /* Set up the LC_CTYPE locale, so we can obtain
- the locale's charset without having to switch
- locales. */
- _Py_SetLocaleFromEnv(LC_CTYPE);
_emit_stderr_warning_for_legacy_locale(core_config);
#endif
@@ -829,6 +825,12 @@ _Py_InitializeCore(PyInterpreterState **interp_p,
(and the input configuration is read only). */
_PyCoreConfig config = _PyCoreConfig_INIT;
+#ifndef MS_WINDOWS
+ /* Set up the LC_CTYPE locale, so we can obtain the locale's charset
+ without having to switch locales. */
+ _Py_SetLocaleFromEnv(LC_CTYPE);
+#endif
+
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
if (_PyCoreConfig_Copy(&config, src_config) >= 0) {
err = _PyCoreConfig_Read(&config);