diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-06-08 15:30:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-08 15:30:39 (GMT) |
commit | d52aa31378ae43e044a300edfe8285954c167216 (patch) | |
tree | a12899c5b00b4b18372ace0f1288a959e0852bda /Lib/subprocess.py | |
parent | 64505a1f6c0af4574e17e823b27ffe24eca44df5 (diff) | |
download | cpython-d52aa31378ae43e044a300edfe8285954c167216.zip cpython-d52aa31378ae43e044a300edfe8285954c167216.tar.gz cpython-d52aa31378ae43e044a300edfe8285954c167216.tar.bz2 |
bpo-30418: Popen.communicate() always ignore EINVAL (#2002)
On Windows, subprocess.Popen.communicate() now also ignore EINVAL
on stdin.write() if the child process is still running but closed the
pipe.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 551aad3..3241758 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -778,19 +778,21 @@ class Popen(object): self.stdin.write(input) except BrokenPipeError: pass # communicate() must ignore broken pipe errors. - except OSError as e: - if e.errno == errno.EINVAL and self.poll() is not None: - # Issue #19612: On Windows, stdin.write() fails with EINVAL - # if the process already exited before the write + except OSError as exc: + if exc.errno == errno.EINVAL: + # bpo-19612, bpo-30418: On Windows, stdin.write() fails + # with EINVAL if the child process exited or if the child + # process is still running but closed the pipe. pass else: raise + try: self.stdin.close() except BrokenPipeError: pass # communicate() must ignore broken pipe errors. - except OSError as e: - if e.errno == errno.EINVAL and self.poll() is not None: + except OSError as exc: + if exc.errno == errno.EINVAL: pass else: raise |