summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-30 10:34:47 (GMT)
committerGitHub <noreply@github.com>2018-11-30 10:34:47 (GMT)
commit55e498058faf8c97840556f6d791c2c392732dc3 (patch)
treeac475e1ca2c6e45b9d9fb9414e86dc2a674b9473 /Python
parenta40700439195a119878150f4f0d425c42ca957ef (diff)
downloadcpython-55e498058faf8c97840556f6d791c2c392732dc3.zip
cpython-55e498058faf8c97840556f6d791c2c392732dc3.tar.gz
cpython-55e498058faf8c97840556f6d791c2c392732dc3.tar.bz2
bpo-35336: Fix PYTHONCOERCECLOCALE=1 (GH-10806)
Fix PYTHONCOERCECLOCALE=1 environment variable: only coerce the C locale if the LC_CTYPE locale is "C".
Diffstat (limited to 'Python')
-rw-r--r--Python/coreconfig.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index ad22300..2fb4e3f 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1061,11 +1061,17 @@ config_read_complex_options(_PyCoreConfig *config)
static void
config_init_locale(_PyCoreConfig *config)
{
- if (config->coerce_c_locale < 0) {
+ /* Test also if coerce_c_locale equals 1: PYTHONCOERCECLOCALE=1 doesn't
+ imply that the C locale is always coerced. It is only coerced if
+ if the LC_CTYPE locale is "C". */
+ if (config->coerce_c_locale != 0) {
/* The C locale enables the C locale coercion (PEP 538) */
if (_Py_LegacyLocaleDetected()) {
config->coerce_c_locale = 1;
}
+ else {
+ config->coerce_c_locale = 0;
+ }
}
#ifndef MS_WINDOWS
@@ -1394,7 +1400,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
}
}
- if (config->utf8_mode < 0 || config->coerce_c_locale < 0) {
+ if (config->coerce_c_locale != 0 || config->utf8_mode < 0) {
config_init_locale(config);
}