(Merge 3.3) Issue #19612: On Windows, subprocess.Popen.communicate() now
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 18 Feb 2014 21:06:35 +0000 (22:06 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 18 Feb 2014 21:06:35 +0000 (22:06 +0100)
ignores OSError(22, 'Invalid argument') when writing input data into stdin,
whereas the process already exited.

1  2 
Lib/subprocess.py
Misc/NEWS

index f47f5ab1dec71ba02c9ffdf1e3703ebc17848cd8,86592a111de18fb8a280c25da0644d6acedf0f77..921670d5a982219f390aaf38c1e60cef9498acc7
@@@ -1185,8 -1192,16 +1185,16 @@@ class Popen(object)
                  if input is not None:
                      try:
                          self.stdin.write(input)
 -                    except IOError as e:
 +                    except OSError as e:
-                         if e.errno != errno.EPIPE:
+                         if e.errno == errno.EPIPE:
 -                            # ignore pipe full error
++                            # communicate() should 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()
  
diff --cc Misc/NEWS
index caad0969fe5c0f32af9f93f3f669f7c574dabb7e,aed4eff0a1d7195c63cd60c441143e8ae05a9da2..42ab220b989e5730bc7574a352d330aef64afb66
+++ b/Misc/NEWS
@@@ -28,15 -20,10 +28,19 @@@ Core and Builtin
  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 #20320: select.select() and select.kqueue.control() now round the
 +  timeout aways from zero, instead of rounding towards zero.
 +
 +- Issue #20616: Add a format() method to tracemalloc.Traceback.
 +
 +- Issue #19744: the ensurepip installation step now just prints a warning to
 +  stderr rather than failing outright if SSL/TLS is unavailable. This allows
 +  local installation of POSIX builds without SSL/TLS support.
 +
  - Issue #6815: os.path.expandvars() now supports non-ASCII environment
    variables names and values.