Skip to content

Commit e5bdad2

Browse files
authored
bpo-30418: Popen.communicate() always ignore EINVAL (#2002) (#2006)
On Windows, subprocess.Popen.communicate() now also ignore EINVAL on stdin.write() if the child process is still running but closed the pipe. (cherry picked from commit d52aa31)
1 parent fe68139 commit e5bdad2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Lib/subprocess.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,11 @@ def _communicate(self, input):
720720
if e.errno == errno.EPIPE:
721721
# communicate() should ignore broken pipe error
722722
pass
723-
elif (e.errno == errno.EINVAL
724-
and self.poll() is not None):
725-
# Issue #19612: stdin.write() fails with EINVAL
726-
# if the process already exited before the write
723+
elif e.errno == errno.EINVAL:
724+
# bpo-19612, bpo-30418: On Windows, stdin.write()
725+
# fails with EINVAL if the child process exited or
726+
# if the child process is still running but closed
727+
# the pipe.
727728
pass
728729
else:
729730
raise

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Extension Modules
4949
Library
5050
-------
5151

52+
- bpo-30418: On Windows, subprocess.Popen.communicate() now also ignore EINVAL
53+
on stdin.write() if the child process is still running but closed the pipe.
54+
5255
- bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
5356
handle IPv6 addresses.
5457

0 commit comments

Comments
 (0)