Under Windows XP, using Python 2.4.2, calling a
subprocess from "subprocess.py" from a script that does
not have a console, with stdin=None (the default) fails.
Since there is a check for stdin=stdout=stderr=None
that just returns, to exhibit this problem you need to
at least set stdout=PIPE (just to get it to run past
the check for that special case).
The problem is that in _get_handles(), l581-582:
if stdin == None:
p2cread = GetStdHandle(STD_INPUT_HANDLE)
GetStdHandle returns None if there is no console. This
is rather nasty bugger of a bug, since I suppose it
breaks most GUI applications that start without the
console (i.e. most) and that eventually invoke
subprocesses and capture their output. I'm surprised
to find this.
To reproduce the problem, do this:
1. save the attached script to C:/temp/bug.py and
C:/temp/bug.pyw
2. create two shortcuts on your desktop to invoke those
scripts
3. open a shell and tail C:/temp/out.log
For bug.py, the log file should display:
2005-11-16 17:38:11,661 INFO 0
For bug.pyw (no console), the log file should show the
following exception:
2005-11-16 17:38:13,084 ERROR Traceback (most recent
call last):
File "C:\Temp\bug.pyw", line 20, in ?
out = call(['C:/Cygwin/bin/ls.exe'], stdout=PIPE)
#, stderr=PIPE)
File "C:\Python24\lib\subprocess.py", line 412, in call
return Popen(*args, **kwargs).wait()
File "C:\Python24\lib\subprocess.py", line 533, in
__init__
(p2cread, p2cwrite,
File "C:\Python24\lib\subprocess.py", line 593, in
_get_handles
p2cread = self._make_inheritable(p2cread)
File "C:\Python24\lib\subprocess.py", line 634, in
_make_inheritable
DUPLICATE_SAME_ACCESS)
TypeError: an integer is required
This is the bug.
Note: in this test program, I'm invoking Cygwin's
ls.exe. Feel free to change it
|