diff options
author | 2019-06-17 01:17:14 -0600 | |
---|---|---|
committer | 2019-06-17 09:17:14 +0200 | |
commit | 28fca0c422b425a6be43be31add0a5328c16b0b8 (patch) | |
tree | af3c6179b46c195c002aee2e30a96e458165cb14 /Python/fileutils.c | |
parent | bpo-37220: Fix 2.7 test -R crash on Windows. (GH-13957) (diff) | |
download | cpython-28fca0c422b425a6be43be31add0a5328c16b0b8.tar.gz cpython-28fca0c422b425a6be43be31add0a5328c16b0b8.tar.bz2 cpython-28fca0c422b425a6be43be31add0a5328c16b0b8.zip |
bpo-37267: Do not check for FILE_TYPE_CHAR in os.dup() on Windows (GH-14051)
On Windows, os.dup() no longer creates an inheritable fd when handling a
character file.
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r-- | Python/fileutils.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 178e2f1268f..93c093f89b4 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -1776,7 +1776,6 @@ _Py_dup(int fd) { #ifdef MS_WINDOWS HANDLE handle; - DWORD ftype; #endif assert(PyGILState_Check()); @@ -1790,9 +1789,6 @@ _Py_dup(int fd) return -1; } - /* get the file type, ignore the error if it failed */ - ftype = GetFileType(handle); - Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH fd = dup(fd); @@ -1803,14 +1799,11 @@ _Py_dup(int fd) return -1; } - /* Character files like console cannot be make non-inheritable */ - if (ftype != FILE_TYPE_CHAR) { - if (_Py_set_inheritable(fd, 0, NULL) < 0) { - _Py_BEGIN_SUPPRESS_IPH - close(fd); - _Py_END_SUPPRESS_IPH - return -1; - } + if (_Py_set_inheritable(fd, 0, NULL) < 0) { + _Py_BEGIN_SUPPRESS_IPH + close(fd); + _Py_END_SUPPRESS_IPH + return -1; } #elif defined(HAVE_FCNTL_H) && defined(F_DUPFD_CLOEXEC) Py_BEGIN_ALLOW_THREADS |