Trent Mick <[EMAIL PROTECTED]> added the comment: The failure is in the DuplicateHandle call that subprocess makes on, in this case, the stdin handle (as returned by `GetStdHandle(STD_INPUT_HANDLE)`) call earlier.
Two cases here: 1. When this is run in a subsystem:windows process (like PythonWin or IDLE) that is launched from Windows Explorer (e.g. from a Start Menu shortcut or Desktop shortcut) then `GetStdHandle(STD_INPUT_HANDLE)` returns None. [http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx] > If an application does not have associated standard handles, > such as a service running on an interactive desktop, and has > not redirected them, the return value is NULL. In this case you *don't* get the error that Todd described, because the code path taken in subprocess.py then use CreatePipe for the `p2cread` variable on which `DuplicateHandle` is called. 2. However, when the subsystem:windows process is launched from the cmd.exe shell the `GetStdHandle` call returns a value -- in Todd's and my testing, the value 3. The code path in subprocess.py then calls `DuplicateHandle` on this in `Popen._make_inheritable`. This fails with traceback Todd posted. My *guess* at what the problem is stems from this comment in the MSDN docs on console handles: [http://msdn.microsoft.com/en-us/library/ms682075(VS.85).aspx] > A process can use the DuplicateHandle function to create a > duplicate console handle that has different access or > inheritability from the original handle. Note, however, > that a process can create a duplicate console handle only > for its own use. This differs from other handle types (such > as file, pipe, or mutex objects), for which DuplicateHandle > can create a duplicate that is valid for a different process. My guess is that the stdin handle (3) is inherited from the shell (cmd.exe) and attempting to `DuplicateHandle` on it violates the clause that you can on dupe a console handle of your own. I'm not sure of that though. Anyone else have more light to shed on this? If this is the case I'm not sure what a possible or good solution could be for subprocess. _______________________________________ 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