[Python-checkins] bpo-34207: Fix pymain_read_conf() for UTF-8 Mode (GH-8868) (GH-8870)
Victor Stinner
webhook-mailer at python.org
Thu Aug 23 06:41:39 EDT 2018
https://github.com/python/cpython/commit/80a0ebaa8385988b1d2dbbbb71ed1f548fc32ad7
commit: 80a0ebaa8385988b1d2dbbbb71ed1f548fc32ad7
branch: 3.7
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-08-23T12:41:35+02:00
summary:
bpo-34207: Fix pymain_read_conf() for UTF-8 Mode (GH-8868) (GH-8870)
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.
(cherry picked from commit 89487f51b8d6ba8a55f5de0ed689e46fefe73cc9)
files:
M Modules/main.c
diff --git a/Modules/main.c b/Modules/main.c
index 6a707c47d503..f82bab2cb1b8 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -1982,6 +1982,7 @@ pymain_read_conf_impl(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
static int
pymain_read_conf(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
{
+ int init_utf8_mode = Py_UTF8Mode;
_PyCoreConfig *config = &pymain->config;
_PyCoreConfig save_config = _PyCoreConfig_INIT;
int res = -1;
@@ -2016,6 +2017,10 @@ pymain_read_conf(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
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, cmdline) < 0) {
goto done;
}
@@ -2086,7 +2091,7 @@ pymain_read_conf(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
setlocale(LC_ALL, oldloc);
PyMem_RawFree(oldloc);
}
-
+ Py_UTF8Mode = init_utf8_mode ;
return res;
}
More information about the Python-checkins
mailing list