Commit d52aa313 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

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.
parent 64505a1f
...@@ -778,19 +778,21 @@ class Popen(object): ...@@ -778,19 +778,21 @@ class Popen(object):
self.stdin.write(input) self.stdin.write(input)
except BrokenPipeError: except BrokenPipeError:
pass # communicate() must ignore broken pipe errors. pass # communicate() must ignore broken pipe errors.
except OSError as e: except OSError as exc:
if e.errno == errno.EINVAL and self.poll() is not None: if exc.errno == errno.EINVAL:
# Issue #19612: On Windows, stdin.write() fails with EINVAL # bpo-19612, bpo-30418: On Windows, stdin.write() fails
# if the process already exited before the write # with EINVAL if the child process exited or if the child
# process is still running but closed the pipe.
pass pass
else: else:
raise raise
try: try:
self.stdin.close() self.stdin.close()
except BrokenPipeError: except BrokenPipeError:
pass # communicate() must ignore broken pipe errors. pass # communicate() must ignore broken pipe errors.
except OSError as e: except OSError as exc:
if e.errno == errno.EINVAL and self.poll() is not None: if exc.errno == errno.EINVAL:
pass pass
else: else:
raise raise
......
...@@ -350,6 +350,9 @@ Extension Modules ...@@ -350,6 +350,9 @@ Extension Modules
Library Library
------- -------
- bpo-30418: On Windows, subprocess.Popen.communicate() now also ignore EINVAL
on stdin.write() if the child process is still running but closed the pipe.
- bpo-30463: Addded empty __slots__ to abc.ABC. This allows subclassers - bpo-30463: Addded empty __slots__ to abc.ABC. This allows subclassers
to deny __dict__ and __weakref__ creation. Patch by Aaron Hall. to deny __dict__ and __weakref__ creation. Patch by Aaron Hall.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment