]> granicus.if.org Git - python/commitdiff
Issue #19612: subprocess.communicate() now also ignores EINVAL when using at
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 28 Jul 2014 22:04:54 +0000 (00:04 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 28 Jul 2014 22:04:54 +0000 (00:04 +0200)
least two pipes.

Lib/subprocess.py
Misc/NEWS

index ce47b5e9ad8d2c9c1027aadf7f29ef21336d76d0..f9e9104d45736b6151cfc3225a63a6b17a7d3d76 100644 (file)
@@ -1035,7 +1035,15 @@ class Popen(object):
                     try:
                         self.stdin.write(input)
                     except IOError as e:
-                        if e.errno != errno.EPIPE:
+                        if e.errno == errno.EPIPE:
+                            # communicate() should ignore broken pipe error
+                            pass
+                        elif (e.errno == errno.EINVAL
+                              and self.poll() is not None):
+                            # Issue #19612: stdin.write() fails with EINVAL
+                            # if the process already exited before the write
+                            pass
+                        else:
                             raise
                 self.stdin.close()
 
index f2087c5c5c8137f219cf45a8bad7e61c7d5fa12b..bdd414ebeb93fb3acef4080b87ae70a2220927b8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #19612: subprocess.communicate() now also ignores EINVAL when using at
+  least two pipes.
+
 - Fix repr(_socket.socket) on Windows 64-bit: don't fail with OverflowError
   on closed socket.