Issue #19612: On Windows, subprocess.Popen.communicate() now ignores
OSError(22, 'Invalid argument') when writing input data into stdin, whereas
the process already exited.
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index d75a4e0..86592a1 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1193,7 +1193,15 @@
                     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()