This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: subprocess works poorly on Windows with Python 2.3
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: astrand, chas17360, reowen
Priority: normal Keywords:

Created on 2004-10-29 21:24 by reowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg22938 - (view) Author: Russell Owen (reowen) Date: 2004-10-29 21:24
My understanding was that was supposed to be 
backwards compatible with at least Python 2.3 if not 2.2. Wanting 
subprocess and backwards compatibility, I grabbed the 
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.
msg22939 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-10-31 07:05
Logged In: YES 

Are you running on Windows 9X, or using 

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. 
msg22940 - (view) Author: Russell Owen (reowen) Date: 2004-11-03 19:11
Logged In: YES 

I am using Windows 2000 Professional. I am not using, 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 

Another possibility is to test the results at your end by editing 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\...
msg22941 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-11-07 16:18
Logged In: YES 

I don't have a "c:\program files" directory on my system,
since it's a Swedish version of Windows. I've tested with
"c:\program\internet explorer\iexplore.exe" instead, but
cannot reproduce the problem: Not with subprocess with 2.4
or 2.3, and not with os.popen3 either. For example, I've tried:

w, r, x = os.popen3('"c:\\program\\internet

Please test and see if you can reproduce the problem with
Internet Explorer. 

As far as I know, it should be safe to install 2.4b1 without
trashing the 2.3 installation. 
msg22942 - (view) Author: Russell Owen (reowen) Date: 2004-11-17 22:03
Logged In: YES 

I tried to follow up on this and today I cannot get it to fail on my system. I 
suggest suspending or closing the bug report. If I figure out what was going 
on and it still seems to be a bug, I'll reopen or file a new report. Sorry for the 
trouble (and thanks for fixing the problem with opening console windows on 
msg22943 - (view) Author: chas17360 (chas17360) Date: 2006-12-13 13:02
I may have found a related problem:

The following appears in function list2cmdline():

            elif c == '"':
                # Double backspaces.
                result.append('\\' * len(bs_buf)*2)
                bs_buf = []

i.e. the character(s) being checked is a double quote, but the comment states 'Double backspaces'.  The code as it is (using Python25) causes a problem when trying to perform a Windows XP copy on a file with whitespace in it's name.  The problem does not occur if the double quote in the code above is replaced by 2 back ticks.
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41103
2004-10-29 21:24:29reowencreate