mirror of https://github.com/python/cpython
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().
This commit is contained in:
parent
7ad6f74fcf
commit
cfb986a1a2
|
@ -247,7 +247,8 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
|
||||||
assert(tstate != NULL);
|
assert(tstate != NULL);
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#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;
|
HANDLE hStdIn, hStdErr;
|
||||||
|
|
||||||
hStdIn = _Py_get_osfhandle_noraise(fileno(sys_stdin));
|
hStdIn = _Py_get_osfhandle_noraise(fileno(sys_stdin));
|
||||||
|
|
|
@ -543,8 +543,11 @@ Py_SetStandardStreamEncoding(const char *encoding, const char *errors)
|
||||||
}
|
}
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
if (_Py_StandardStreamEncoding) {
|
if (_Py_StandardStreamEncoding) {
|
||||||
|
_Py_COMP_DIAG_PUSH
|
||||||
|
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||||
/* Overriding the stream encoding implies legacy streams */
|
/* Overriding the stream encoding implies legacy streams */
|
||||||
Py_LegacyWindowsStdioFlag = 1;
|
Py_LegacyWindowsStdioFlag = 1;
|
||||||
|
_Py_COMP_DIAG_POP
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue