summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-17 01:45:04 -0700
committerVictor Stinner <vstinner@redhat.com>2019-06-17 10:45:04 +0200
commit71589491ad0da27f57789b97354f6094a91e2eb3 (patch)
tree80e64e545573b4391deb32352eb88e86e35cc830 /Python
parent351b0e793e35510e8cbbcbb455a1b9544e808cdd (diff)
downloadcpython-git-71589491ad0da27f57789b97354f6094a91e2eb3.tar.gz
bpo-37267: Do not check for FILE_TYPE_CHAR in os.dup() on Windows (GH-14051) (GH-14141)
On Windows, os.dup() no longer creates an inheritable fd when handling a character file. (cherry picked from commit 28fca0c422b425a6be43be31add0a5328c16b0b8) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/fileutils.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 5e71d37526..868fbf9103 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1659,7 +1659,6 @@ _Py_dup(int fd)
{
#ifdef MS_WINDOWS
HANDLE handle;
- DWORD ftype;
#endif
assert(PyGILState_Check());
@@ -1673,9 +1672,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);
@@ -1686,14 +1682,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