summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/coreconfig.c18
-rw-r--r--Python/pylifecycle.c10
2 files changed, 16 insertions, 12 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index d08d75b196..8724681a79 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -671,16 +671,18 @@ config_read_env_vars(_PyCoreConfig *config)
config->malloc_stats = 1;
}
- if (config->coerce_c_locale < 0) {
- const char *env = _PyCoreConfig_GetEnv(config, "PYTHONCOERCECLOCALE");
- if (env) {
- if (strcmp(env, "0") == 0) {
+ const char *env = _PyCoreConfig_GetEnv(config, "PYTHONCOERCECLOCALE");
+ if (env) {
+ if (strcmp(env, "0") == 0) {
+ if (config->coerce_c_locale < 0) {
config->coerce_c_locale = 0;
}
- else if (strcmp(env, "warn") == 0) {
- config->coerce_c_locale_warn = 1;
- }
- else {
+ }
+ else if (strcmp(env, "warn") == 0) {
+ config->coerce_c_locale_warn = 1;
+ }
+ else {
+ if (config->coerce_c_locale < 0) {
config->coerce_c_locale = 1;
}
}
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 29711dfc98..4d248ede9c 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -659,10 +659,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
@@ -815,6 +811,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);