summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorSegev Finer <segev208@gmail.com>2017-08-18 16:18:13 +0300
committerVictor Stinner <victor.stinner@gmail.com>2017-08-18 15:18:13 +0200
commit4d3851727fb82195e4995c6064b0b2d6cbc031c4 (patch)
treed39c125eded8ac59a4108465ff9fbea47c730628 /Lib/subprocess.py
parenta7c449b8c08933deabcf329fb74ed1336f6db34f (diff)
downloadcpython-git-4d3851727fb82195e4995c6064b0b2d6cbc031c4.tar.gz
bpo-30121: Fix debug assert in subprocess on Windows (#1224)
* bpo-30121: Fix debug assert in subprocess on Windows This is caused by closing HANDLEs using os.close which is for CRT file descriptors and not for HANDLEs. * bpo-30121: Suppress debug assertion in test_subprocess when ran directly
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 99bca477ce..2805ec3fa3 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -727,7 +727,10 @@ class Popen(object):
to_close.append(self._devnull)
for fd in to_close:
try:
- os.close(fd)
+ if _mswindows and isinstance(fd, Handle):
+ fd.Close()
+ else:
+ os.close(fd)
except OSError:
pass
@@ -1007,6 +1010,9 @@ class Popen(object):
errwrite.Close()
if hasattr(self, '_devnull'):
os.close(self._devnull)
+ # Prevent a double close of these handles/fds from __init__
+ # on error.
+ self._closed_child_pipe_fds = True
# Retain the process handle, but close the thread handle
self._child_created = True