]> granicus.if.org Git - python/commitdiff
Issue #19612: On Windows, subprocess.Popen.communicate() now ignores
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 18 Feb 2014 21:00:53 +0000 (22:00 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 18 Feb 2014 21:00:53 +0000 (22:00 +0100)
OSError(22, 'Invalid argument') when writing input data into stdin, whereas
the process already exited.

Lib/subprocess.py
Misc/NEWS

index d75a4e04044554c79aa8eb78ae9d8d03cc6ab4d7..86592a111de18fb8a280c25da0644d6acedf0f77 100644 (file)
@@ -1193,7 +1193,15 @@ class Popen(object):
                     try:
                         self.stdin.write(input)
                     except IOError as e:
-                        if e.errno != errno.EPIPE:
+                        if e.errno == errno.EPIPE:
+                            # ignore pipe full 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 211114747f3621ce70b6b984a69af9f8600e6a7d..aed4eff0a1d7195c63cd60c441143e8ae05a9da2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #19612: On Windows, subprocess.Popen.communicate() now ignores
+  OSError(22, 'Invalid argument') when writing input data into stdin, whereas
+  the process already exited.
+
 - Issue #6815: os.path.expandvars() now supports non-ASCII environment
   variables names and values.
 
@@ -27,7 +31,7 @@ Library
   Based on patch by Stephen Tu.
 
 - Issue #8478: Untokenizer.compat processes first token from iterator input.
-  Patch based on lines from Georg Brandl, Eric Snow, and Gareth Rees.  
+  Patch based on lines from Georg Brandl, Eric Snow, and Gareth Rees.
 
 - Issue #20594: Avoid name clash with the libc function posix_close.