diff options
author | Segev Finer <segev208@gmail.com> | 2021-04-23 22:00:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-23 22:00:27 (GMT) |
commit | 5e437fb872279960992c9a07f1a4c051b4948c53 (patch) | |
tree | da3e3ad584eba24da9cfe63c4acd1a01e55d4676 /Parser | |
parent | 6b59e662fa39a356d6eb03d349b140477857f4b1 (diff) | |
download | cpython-5e437fb872279960992c9a07f1a4c051b4948c53.zip cpython-5e437fb872279960992c9a07f1a4c051b4948c53.tar.gz cpython-5e437fb872279960992c9a07f1a4c051b4948c53.tar.bz2 |
bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection (GH-1927)
This works by not caching the handle and instead getting the handle from
the file descriptor each time, so that if the actual handle changes by
fd redirection closing/opening the console handle beneath our feet, we
will keep working correctly.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/myreadline.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Parser/myreadline.c b/Parser/myreadline.c index 143b41f..e5e2fb1 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -249,10 +249,8 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt) if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) { HANDLE hStdIn, hStdErr; - _Py_BEGIN_SUPPRESS_IPH - hStdIn = (HANDLE)_get_osfhandle(fileno(sys_stdin)); - hStdErr = (HANDLE)_get_osfhandle(fileno(stderr)); - _Py_END_SUPPRESS_IPH + hStdIn = _Py_get_osfhandle_noraise(fileno(sys_stdin)); + hStdErr = _Py_get_osfhandle_noraise(fileno(stderr)); if (_get_console_type(hStdIn) == 'r') { fflush(sys_stdout); |