Skip to content

Commit

Permalink
gh-93937: PyOS_StdioReadline() uses PyConfig.legacy_windows_stdio (#9…
Browse files Browse the repository at this point in the history
…4024)

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().
  • Loading branch information
vstinner committed Jun 20, 2022
1 parent 7ad6f74 commit cfb986a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Parser/myreadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cfb986a

Please sign in to comment.