Bugs item #1358527, was opened at 2005-11-16 23:59 Message generated for change (Comment added) made by astrand You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1358527&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 >Status: Closed >Resolution: Duplicate Priority: 5 Private: No Submitted By: Martin Blais (blais) Assigned to: Peter Åstrand (astrand) Summary: subprocess.py fails on Windows when there is no console Initial Comment: 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 ---------------------------------------------------------------------- >Comment By: Peter Åstrand (astrand) Date: 2007-01-22 20:27 Message: Logged In: YES user_id=344921 Originator: NO Duplicate of 1124861. ---------------------------------------------------------------------- Comment By: Martin Blais (blais) Date: 2005-11-17 14:41 Message: Logged In: YES user_id=10996 Here is an example of a workaround: p = Popen(ps2pdf, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=tempfile.gettempdir()) p.stdin.close() # FIXME: we need to specify and close stdin explicitly # because of a bug I found and reported in subprocess.py # when the program is launched without a console, see SF bug # tracker for the Python project for details. When the bug # gets fixed we should be able to remove this. Basically I just specify stdin=PIPE and close it by hand. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1358527&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com