diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-09-03 15:32:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-03 15:32:31 (GMT) |
commit | 73b00becbdd40f6a80cfa00abf1ae650a2b5e454 (patch) | |
tree | be23ad51bb194b21a928d874069e6e6ffc3bd799 /Modules/main.c | |
parent | 2094c2bea4f79c31819994d8f0afa97ccc52cca8 (diff) | |
download | cpython-73b00becbdd40f6a80cfa00abf1ae650a2b5e454.zip cpython-73b00becbdd40f6a80cfa00abf1ae650a2b5e454.tar.gz cpython-73b00becbdd40f6a80cfa00abf1ae650a2b5e454.tar.bz2 |
bpo-34544: pymain_read_conf() don't change LC_ALL (GH-9045)
bpo-34485, bpo-34544: Again, pymain_read_conf() leaves LC_ALL locale
unchanged: only modify LC_CTYPE.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/Modules/main.c b/Modules/main.c index 6f817b6..455178a 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1291,18 +1291,7 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag; #endif _PyCoreConfig save_config = _PyCoreConfig_INIT; - char *oldloc = NULL; int res = -1; - - oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); - if (oldloc == NULL) { - pymain->err = _Py_INIT_NO_MEMORY(); - goto done; - } - - /* Reconfigure the locale to the default for this process */ - _Py_SetLocaleFromEnv(LC_ALL); - int locale_coerced = 0; int loops = 0; @@ -1311,6 +1300,9 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, goto done; } + /* Set LC_CTYPE to the user preferred locale */ + _Py_SetLocaleFromEnv(LC_CTYPE); + while (1) { int utf8_mode = config->utf8_mode; int encoding_changed = 0; @@ -1392,10 +1384,6 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, done: _PyCoreConfig_Clear(&save_config); - if (oldloc != NULL) { - setlocale(LC_ALL, oldloc); - PyMem_RawFree(oldloc); - } Py_UTF8Mode = init_utf8_mode ; #ifdef MS_WINDOWS Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding; |