[ python-Bugs-1057048 ] subprocess works poorly on Windows with Python 2.3

SourceForge.net noreply at sourceforge.net
Wed Nov 3 20:11:45 CET 2004


Bugs item #1057048, was opened at 2004-10-29 14:24
Message generated for change (Comment added) made by reowen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1057048&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Russell Owen (reowen)
Assigned to: Nobody/Anonymous (nobody)
Summary: subprocess works poorly on Windows with Python 2.3

Initial Comment:
My understanding was that subprocess.py was supposed to be 
backwards compatible with at least Python 2.3 if not 2.2. Wanting 
subprocess and backwards compatibility, I grabbed the subprocess.py 
from 2.4b1, changed the import if so that win32api was used (since I 
had no _subprocess library!) and found several problems, of which 
this is one (one per bug report):

If the executable has a space in its path name (as is standard on 
Windows) and command-line arguments, things fail miserably:

from subprocess import *
Popen('"C:\Program Files\ds9\xpaget" ds9 mode')

produces an error that C:\Program cannot be run. Clearly the double 
quoting isn't making it through Popen. Note that this runs just fine if 
there are no command line arguments, i.e. this works:

Popen('"C:\Program Files\ds9\xpaget"')

Note that this same bug also exists in os.popen3, so you may have 
inherited it.

This bug does NOT occur on a unix build on MacOS X.

----------------------------------------------------------------------

>Comment By: Russell Owen (reowen)
Date: 2004-11-03 11:11

Message:
Logged In: YES 
user_id=431773

I am using Windows 2000 Professional. I am not using command.com, at 
least not that I know of. I'm running my program from PythonWin or IDLE 
(most often the former).

Can I safely install 2.4b1 and not trash my 2.3 install? If so, I'll give it a go. 
(I know this works on Mac and unix, but have no idea how it works on 
Windows).

Another possibility is to test the results at your end by editing 
subprocess.py to toggle that flag that makes win32api be used instead of 
_subprocess. Then launching any app using an explicit path should show the 
problem (or not), since they are all in C:\Program Files\...

----------------------------------------------------------------------

Comment By: Peter Åstrand (astrand)
Date: 2004-10-31 00:05

Message:
Logged In: YES 
user_id=344921

Are you running on Windows 9X, or using command.com? 

If you are using shell=False (as in your example),
subprocess doesn't change the argument string in any way: It
is passed directly to CreateProcess. 

Can you confirm that the problem only exists with Python
2.3, and not with 2.4? In that case, it might be a bug in
win32api:s CreateProcess. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1057048&group_id=5470


More information about the Python-bugs-list mailing list