[Python-checkins] gh-106659: Fix test_embed.test_forced_io_encoding() on Windows (#108010)

vstinner webhook-mailer at python.org
Wed Aug 16 07:57:03 EDT 2023


https://github.com/python/cpython/commit/e35c722d22cae605b485e75a69238dc44aab4c96
commit: e35c722d22cae605b485e75a69238dc44aab4c96
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2023年08月16日T11:56:56Z
summary:
gh-106659: Fix test_embed.test_forced_io_encoding() on Windows (#108010)
Use config.legacy_windows_stdio=1 to avoid _io._WindowsConsoleIO.
files:
M Doc/whatsnew/3.13.rst
M Programs/_testembed.c
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index a65a98bae1357..84ffd84b9f0bb 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -941,7 +941,9 @@ Removed
 * ``Py_SetPath()``: set :c:member:`PyConfig.module_search_paths` instead.
 * ``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead.
 * ``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead.
- * ``Py_SetStandardStreamEncoding()``: set :c:member:`PyConfig.stdio_encoding` instead.
+ * ``Py_SetStandardStreamEncoding()``: set :c:member:`PyConfig.stdio_encoding`
+ instead, and set also maybe :c:member:`PyConfig.legacy_windows_stdio` (on
+ Windows).
 * ``_Py_SetProgramFullPath()``: set :c:member:`PyConfig.executable` instead.
 
 Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 351cdc302e8cb..7ee64b22925f0 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -237,6 +237,11 @@ static void check_stdio_details(const wchar_t *encoding, const wchar_t *errors)
 if (errors) {
 config_set_string(&config, &config.stdio_errors, errors);
 }
+#ifdef MS_WINDOWS
+ // gh-106659: On Windows, don't use _io._WindowsConsoleIO which always
+ // announce UTF-8 for sys.stdin.encoding.
+ config.legacy_windows_stdio = 1;
+#endif
 config_set_program_name(&config);
 init_from_config_clear(&config);
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /