New submission from Todd Whiteman <[EMAIL PROTECTED]>: I'm getting a 'The handle is invalid' error when using subprocess.Popen in Python 2.5 (and 2.6). If any of the stdio handles are somehow invalid or not real io handles (fd is not 0, 1 or 2), and you are not telling subprocess to PIPE all of the handles, then subprocess throws the following exception.
The easiest way to reproduce this is using run PythonWin from a Windows Command Prompt: C:\Python\Lib\site-packages\pythonwin\Pythonwin.exe and then use the following 2 subprocess code lines below: import subprocess p = subprocess.Popen(["python", "-c", "print 32"], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python26\lib\subprocess.py", line 588, in init_ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Python26\lib\subprocess.py", line 703, in _get_handles p2cread = self._make_inheritable(p2cread) File "C:\Python26\lib\subprocess.py", line 748, in _make_inheritable DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid Specifying PIPE for all subprocess.Popen handles is the only way I've found to get around this problem: p = subprocess.Popen(["python", "-c", "print 32"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.stdin.close() p.communicate() ('32\r\n', '') ---------- components: Windows messages: 73408 nosy: trentm, twhitema severity: normal status: open title: subprocess failing in GUI applications on Windows versions: Python 2.5, Python 2.6 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3905> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com