Skip to content

Commit cfb986a

Browse files
authored
gh-93937: PyOS_StdioReadline() uses PyConfig.legacy_windows_stdio (#94024)
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().
1 parent 7ad6f74 commit cfb986a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: Parser/myreadline.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
247247
assert(tstate != NULL);
248248

249249
#ifdef MS_WINDOWS
250-
if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) {
250+
const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
251+
if (!config->legacy_windows_stdio && sys_stdin == stdin) {
251252
HANDLE hStdIn, hStdErr;
252253

253254
hStdIn = _Py_get_osfhandle_noraise(fileno(sys_stdin));

Diff for: Python/initconfig.c

+3
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,11 @@ Py_SetStandardStreamEncoding(const char *encoding, const char *errors)
543543
}
544544
#ifdef MS_WINDOWS
545545
if (_Py_StandardStreamEncoding) {
546+
_Py_COMP_DIAG_PUSH
547+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
546548
/* Overriding the stream encoding implies legacy streams */
547549
Py_LegacyWindowsStdioFlag = 1;
550+
_Py_COMP_DIAG_POP
548551
}
549552
#endif
550553

0 commit comments

Comments
 (0)