diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-08-23 10:23:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 10:23:46 (GMT) |
commit | 89487f51b8d6ba8a55f5de0ed689e46fefe73cc9 (patch) | |
tree | 8a795e9d3e3ad56988c7c4cd3baaf0b0d30826e7 /Modules/main.c | |
parent | ccd99752675042bd5f67d332c5b0ed85ba1f2da3 (diff) | |
download | cpython-89487f51b8d6ba8a55f5de0ed689e46fefe73cc9.zip cpython-89487f51b8d6ba8a55f5de0ed689e46fefe73cc9.tar.gz cpython-89487f51b8d6ba8a55f5de0ed689e46fefe73cc9.tar.bz2 |
bpo-34207: Fix pymain_read_conf() for UTF-8 Mode (GH-8868)
bpo-34170, bpo-34207: pymain_read_conf() now sets Py_UTF8Mode to
config->utf8_mode. pymain_read_conf() calls indirectly
Py_DecodeLocale() and Py_EncodeLocale() which depend on Py_UTF8Mode.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/main.c b/Modules/main.c index 1640758..992d720 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1286,6 +1286,7 @@ static int pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, _PyCmdline *cmdline) { + int init_utf8_mode = Py_UTF8Mode; _PyCoreConfig save_config = _PyCoreConfig_INIT; char *oldloc = NULL; int res = -1; @@ -1319,6 +1320,10 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, goto done; } + /* bpo-34207: Py_DecodeLocale(), Py_EncodeLocale() and similar + functions depend on Py_UTF8Mode. */ + Py_UTF8Mode = config->utf8_mode; + if (pymain_init_cmdline_argv(pymain, config, cmdline) < 0) { goto done; } @@ -1383,6 +1388,7 @@ done: setlocale(LC_ALL, oldloc); PyMem_RawFree(oldloc); } + Py_UTF8Mode = init_utf8_mode ; return res; } |