This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2017-05-21.02:00:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495332022.44.0.641336080565.issue30418@psf.upfronthosting.co.za>
In-reply-to
Content
Seeing EINVAL here while the child process is alive could mean the read end of the pipe was closed. For example:

    >>> import time, subprocess
    >>> cmd = 'python -c "import os, time; os.close(0); time.sleep(15)"'
    >>> p = subprocess.Popen(cmd, stdin=subprocess.PIPE, bufsize=0)
    >>> time.sleep(5); p.communicate(b'spam')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Program Files\Python36\lib\subprocess.py", line 821, in communicate
        self._stdin_write(input)
      File "C:\Program Files\Python36\lib\subprocess.py", line 776, in _stdin_write
        self.stdin.write(input)
    OSError: [Errno 22] Invalid argument

If buffered, the error would instead occur at self.stdin.close(). Both cases are currently checked, but the error is only ignored when the child process is still alive.

The underlying Windows error is ERROR_NO_DATA. If we could know that for certain, then we could ignore it as a BrokenPipeError. Currently all we have to go on from _Py_write is the CRT's EINVAL errno value. In contrast, when creating an OSError from the Windows last error value, winerror_to_errno() maps ERROR_NO_DATA as EPIPE.
History
Date User Action Args
2017-05-21 02:00:22eryksunsetrecipients: + eryksun, paul.moore, vstinner, tim.golden, zach.ware, steve.dower
2017-05-21 02:00:22eryksunsetmessageid: <1495332022.44.0.641336080565.issue30418@psf.upfronthosting.co.za>
2017-05-21 02:00:22eryksunlinkissue30418 messages
2017-05-21 02:00:21eryksuncreate