[Python-checkins] cpython (2.7): Issue #19612: subprocess.communicate() now also ignores EINVAL when using at

victor.stinner python-checkins at python.org
Tue Jul 29 00:07:14 CEST 2014


http://hg.python.org/cpython/rev/039ac3f01c4e
changeset:   91905:039ac3f01c4e
branch:      2.7
parent:      91895:bffa0b8a16e8
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jul 29 00:04:54 2014 +0200
summary:
  Issue #19612: subprocess.communicate() now also ignores EINVAL when using at
least two pipes.

files:
  Lib/subprocess.py |  10 +++++++++-
  Misc/NEWS         |   3 +++
  2 files changed, 12 insertions(+), 1 deletions(-)


diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1035,7 +1035,15 @@
                     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()
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list