]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30418: Popen.communicate() always ignore EINVAL (#2002) (#2005)
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 8 Jun 2017 16:20:46 +0000 (18:20 +0200)
committerGitHub <noreply@github.com>
Thu, 8 Jun 2017 16:20:46 +0000 (18:20 +0200)
On Windows, subprocess.Popen.communicate() now also ignore EINVAL
on stdin.write() if the child process is still running but closed the
pipe.
(cherry picked from commit d52aa31378ae43e044a300edfe8285954c167216)

Lib/subprocess.py
Misc/NEWS

index 281ea8af92257e6da62e297ab7420165cfbdfa39..614de40e5cae32fb36b8b73d109a9a20a16648c3 100644 (file)
@@ -741,19 +741,21 @@ class Popen(object):
                 self.stdin.write(input)
             except BrokenPipeError:
                 pass  # communicate() must ignore broken pipe errors.
-            except OSError as e:
-                if e.errno == errno.EINVAL and self.poll() is not None:
-                    # Issue #19612: On Windows, stdin.write() fails with EINVAL
-                    # if the process already exited before the write
+            except OSError as exc:
+                if exc.errno == errno.EINVAL:
+                    # bpo-19612, bpo-30418: On Windows, stdin.write() fails
+                    # with EINVAL if the child process exited or if the child
+                    # process is still running but closed the pipe.
                     pass
                 else:
                     raise
+
         try:
             self.stdin.close()
         except BrokenPipeError:
             pass  # communicate() must ignore broken pipe errors.
-        except OSError as e:
-            if e.errno == errno.EINVAL and self.poll() is not None:
+        except OSError as exc:
+            if exc.errno == errno.EINVAL:
                 pass
             else:
                 raise
index 997058b34a55929dbb75f26855dc3c77689075e6..78ec9f0ccae64ab75654269c1cb89d1994298795 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -56,6 +56,9 @@ Extension Modules
 Library
 -------
 
+- bpo-30418: On Windows, subprocess.Popen.communicate() now also ignore EINVAL
+  on stdin.write() if the child process is still running but closed the pipe.
+
 - bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
   handle IPv6 addresses.