summaryrefslogtreecommitdiffstats
path: root/Python/coreconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-28 22:16:53 (GMT)
committerGitHub <noreply@github.com>2018-08-28 22:16:53 (GMT)
commit2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab (patch)
tree30ec358a0f7947a398b2ed25eb416c92acaff2b6 /Python/coreconfig.c
parent9e4994d410970fb4e75168401d159ba47a8f7108 (diff)
downloadcpython-2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab.zip
cpython-2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab.tar.gz
cpython-2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab.tar.bz2
bpo-34485: Fix _Py_InitializeCore() for C locale coercion (GH-8979)
* _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.
Diffstat (limited to 'Python/coreconfig.c')
-rw-r--r--Python/coreconfig.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index d08d75b..8724681 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;
}
}