]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106659: Fix test_embed.test_forced_io_encoding() on Windows (#108010)
authorVictor Stinner <vstinner@python.org>
Wed, 16 Aug 2023 11:56:56 +0000 (13:56 +0200)
committerGitHub <noreply@github.com>
Wed, 16 Aug 2023 11:56:56 +0000 (11:56 +0000)
Use config.legacy_windows_stdio=1 to avoid _io._WindowsConsoleIO.

Doc/whatsnew/3.13.rst
Programs/_testembed.c

index a65a98bae13579ea80085dbac08cc341a83b122d..84ffd84b9f0bb623278f2dd5b406fb0189fbeeda 100644 (file)
@@ -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
index 351cdc302e8cb0085fbe1c3e96ae0ce2fabdfc8e..7ee64b22925f0c6239dfb14c8838084ac74878f2 100644 (file)
@@ -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);