diff options
author | Segev Finer <segev208@gmail.com> | 2017-08-18 13:18:13 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-08-18 13:18:13 (GMT) |
commit | 4d3851727fb82195e4995c6064b0b2d6cbc031c4 (patch) | |
tree | d39c125eded8ac59a4108465ff9fbea47c730628 /Lib/subprocess.py | |
parent | a7c449b8c08933deabcf329fb74ed1336f6db34f (diff) | |
download | cpython-4d3851727fb82195e4995c6064b0b2d6cbc031c4.zip cpython-4d3851727fb82195e4995c6064b0b2d6cbc031c4.tar.gz cpython-4d3851727fb82195e4995c6064b0b2d6cbc031c4.tar.bz2 |
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.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 99bca47..2805ec3 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 |