Skip to content

Commit e35c722

Browse files
authored
gh-106659: Fix test_embed.test_forced_io_encoding() on Windows (#108010)
Use config.legacy_windows_stdio=1 to avoid _io._WindowsConsoleIO.
1 parent 57a20b0 commit e35c722

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Doc/whatsnew/3.13.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,9 @@ Removed
941941
* ``Py_SetPath()``: set :c:member:`PyConfig.module_search_paths` instead.
942942
* ``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead.
943943
* ``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead.
944-
* ``Py_SetStandardStreamEncoding()``: set :c:member:`PyConfig.stdio_encoding` instead.
944+
* ``Py_SetStandardStreamEncoding()``: set :c:member:`PyConfig.stdio_encoding`
945+
instead, and set also maybe :c:member:`PyConfig.legacy_windows_stdio` (on
946+
Windows).
945947
* ``_Py_SetProgramFullPath()``: set :c:member:`PyConfig.executable` instead.
946948

947949
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization

Programs/_testembed.c

+5
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ static void check_stdio_details(const wchar_t *encoding, const wchar_t *errors)
237237
if (errors) {
238238
config_set_string(&config, &config.stdio_errors, errors);
239239
}
240+
#ifdef MS_WINDOWS
241+
// gh-106659: On Windows, don't use _io._WindowsConsoleIO which always
242+
// announce UTF-8 for sys.stdin.encoding.
243+
config.legacy_windows_stdio = 1;
244+
#endif
240245
config_set_program_name(&config);
241246
init_from_config_clear(&config);
242247

0 commit comments

Comments
 (0)