summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-29 17:32:47 (GMT)
committerGitHub <noreply@github.com>2018-08-29 17:32:47 (GMT)
commitc5989cd87659acbfd4d19dc00dbe99c3a0fc9bd2 (patch)
tree9bd325d65e1cee9696fb98998db0bdb2a2e21b41 /Modules/main.c
parent70fead25e503a742ad4c919b151b9b2b5facee36 (diff)
downloadcpython-c5989cd87659acbfd4d19dc00dbe99c3a0fc9bd2.zip
cpython-c5989cd87659acbfd4d19dc00dbe99c3a0fc9bd2.tar.gz
cpython-c5989cd87659acbfd4d19dc00dbe99c3a0fc9bd2.tar.bz2
bpo-34523: Py_DecodeLocale() use UTF-8 on Windows (GH-8998)
Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero. pymain_read_conf() now sets Py_LegacyWindowsFSEncodingFlag in its loop, but restore its value at exit.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 2e9e23b..bf7290a 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -1287,6 +1287,9 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
_PyCmdline *cmdline)
{
int init_utf8_mode = Py_UTF8Mode;
+#ifdef MS_WINDOWS
+ int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag;
+#endif
_PyCoreConfig save_config = _PyCoreConfig_INIT;
int res = -1;
@@ -1313,9 +1316,12 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
goto done;
}
- /* bpo-34207: Py_DecodeLocale(), Py_EncodeLocale() and similar
- functions depend on Py_UTF8Mode. */
+ /* bpo-34207: Py_DecodeLocale() and Py_EncodeLocale() depend
+ on Py_UTF8Mode and Py_LegacyWindowsFSEncodingFlag. */
Py_UTF8Mode = config->utf8_mode;
+#ifdef MS_WINDOWS
+ Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding;
+#endif
if (pymain_init_cmdline_argv(pymain, config, cmdline) < 0) {
goto done;
@@ -1380,6 +1386,9 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
done:
_PyCoreConfig_Clear(&save_config);
Py_UTF8Mode = init_utf8_mode ;
+#ifdef MS_WINDOWS
+ Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding;
+#endif
return res;
}