Use config.legacy_windows_stdio=1 to avoid _io._WindowsConsoleIO.
* ``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
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);