]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93937: PyOS_StdioReadline() uses PyConfig.legacy_windows_stdio (#94024)
authorVictor Stinner <vstinner@python.org>
Mon, 20 Jun 2022 14:10:47 +0000 (16:10 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Jun 2022 14:10:47 +0000 (16:10 +0200)
On Windows, PyOS_StdioReadline() now gets
PyConfig.legacy_windows_stdio from _PyOS_ReadlineTState, rather than
using the deprecated global Py_LegacyWindowsStdioFlag variable.

Fix also a compiler warning in Py_SetStandardStreamEncoding().

Parser/myreadline.c
Python/initconfig.c

index b10d306255bb67847cc96a2c61e049d53366b9ae..d55fcefbb6f206e7d7490754bf65fafb54e90fbd 100644 (file)
@@ -247,7 +247,8 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
     assert(tstate != NULL);
 
 #ifdef MS_WINDOWS
-    if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) {
+    const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
+    if (!config->legacy_windows_stdio && sys_stdin == stdin) {
         HANDLE hStdIn, hStdErr;
 
         hStdIn = _Py_get_osfhandle_noraise(fileno(sys_stdin));
index 62f1f67473d57efd64a2c5db12c1e31918fb9203..355f9869290bbd744e5c9d51638e6e281dfa6826 100644 (file)
@@ -543,8 +543,11 @@ Py_SetStandardStreamEncoding(const char *encoding, const char *errors)
     }
 #ifdef MS_WINDOWS
     if (_Py_StandardStreamEncoding) {
+_Py_COMP_DIAG_PUSH
+_Py_COMP_DIAG_IGNORE_DEPR_DECLS
         /* Overriding the stream encoding implies legacy streams */
         Py_LegacyWindowsStdioFlag = 1;
+_Py_COMP_DIAG_POP
     }
 #endif