Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f47ac2

Browse files
committed
(Merge 3.3) Issue #19612: On Windows, subprocess.Popen.communicate() now
ignores OSError(22, 'Invalid argument') when writing input data into stdin, whereas the process already exited.
2 parents 9a0cbcc + d5c8ce7 commit 5f47ac2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lib/subprocess.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,15 @@ def _communicate(self, input, endtime, orig_timeout):
11861186
try:
11871187
self.stdin.write(input)
11881188
except OSError as e:
1189-
if e.errno != errno.EPIPE:
1189+
if e.errno == errno.EPIPE:
1190+
# communicate() should ignore pipe full error
1191+
pass
1192+
elif (e.errno == errno.EINVAL
1193+
and self.poll() is not None):
1194+
# Issue #19612: stdin.write() fails with EINVAL
1195+
# if the process already exited before the write
1196+
pass
1197+
else:
11901198
raise
11911199
self.stdin.close()
11921200

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Core and Builtins
2828
Library
2929
-------
3030

31+
- Issue #19612: On Windows, subprocess.Popen.communicate() now ignores
32+
OSError(22, 'Invalid argument') when writing input data into stdin, whereas
33+
the process already exited.
34+
3135
- Issue #20320: select.select() and select.kqueue.control() now round the
3236
timeout aways from zero, instead of rounding towards zero.
3337

0 commit comments

Comments
 (0)