[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

Tim Golden report at bugs.python.org
Wed Nov 14 16:20:01 CET 2012


Tim Golden added the comment:

On 13/11/2012 20:57, Karthk Rajagopalan wrote:
> I added test case using perl and python since it was easy to
> reproduce using perl socket module and show the issue happening with
> python's subprocess.py. There is definitely an action required in
> subprocess.py to catch 'invalid handle error' and my attached patch
> handle this situation.

So, because subprocess.call includes a call to DuplicateHandle(stdin),
that call will fail if stdin is currently a handle to a socket.
Is that right?

Your patch fails to apply cleanly to the hg tip, because Gregory P.
Smith has been making changes in this very piece of code over the last
few days. I'll add him as interested to the call as someone who can make
a call as to the suitability of your patch.

> I can come up with a test case like perl does to create a listening
> socket and map the socket handle to a file descriptor. You will see
> this issue *only* when the open_osfhandle(..) is used to map the
> handle to a file descriptor.

If this is to go ahead, we will need a test case which can run as part
of the Python stdlib tests, and perl is not part of that stdlib!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16458>
_______________________________________


More information about the Python-bugs-list mailing list