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 /Modules/posixmodule.c | |
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 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index e754db7..ecd210e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -10098,18 +10098,16 @@ os_pipe_impl(PyObject *module) attr.bInheritHandle = FALSE; Py_BEGIN_ALLOW_THREADS - _Py_BEGIN_SUPPRESS_IPH ok = CreatePipe(&read, &write, &attr, 0); if (ok) { - fds[0] = _open_osfhandle((intptr_t)read, _O_RDONLY); - fds[1] = _open_osfhandle((intptr_t)write, _O_WRONLY); + fds[0] = _Py_open_osfhandle_noraise(read, _O_RDONLY); + fds[1] = _Py_open_osfhandle_noraise(write, _O_WRONLY); if (fds[0] == -1 || fds[1] == -1) { CloseHandle(read); CloseHandle(write); ok = 0; } } - _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS if (!ok) |