[issue5484] subprocess.call() fails for .bat files on Windows, if executable path contains parenthesis

Tim Golden report at bugs.python.org
Fri Mar 13 21:20:06 CET 2009


Tim Golden <mail at timgolden.me.uk> added the comment:

Erik Sandberg wrote:
> Erik Sandberg <sandberg at virtutech.com> added the comment:
> 
> Did you test your code? 

Several times, cutting and pasting into the Python interpreter.
But I missed the fact that you were running Python 2.5

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC
Type "help", "copyright", "credits" or "license" for m
>>> import subprocess
>>> open ("t(o.bat", "w").write ("echo we are here\n")
>>> subprocess.call (["t(o.bat"])

c:\temp>echo we are here
we are here
0
>>>

Testing under 2.5 shows the issue you describe

However, I doubt very much whether any change would be
made to 2.5 at this point anyway: I think it's in
security-bug-fix-only  mode now. Bizarrely, I can't
see any reason why the behaviour should have changed.
Might even be the runtime it links to.

> (this guess is based on what I read in msdn.com's docs on CreateProcess:
> """To run a batch file, you must start the command interpreter; set
> lpApplicationName to cmd.exe and set lpCommandLine to the following
> arguments: /c plus the name of the batch file.""")

In fact, the shell=True code on Windows basically does:

%COMSPEC% /c args... 

for you behind the scenes. But, as my example above shows,
you don't seem to need to do that in any case.

TJG

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5484>
_______________________________________


More information about the Python-bugs-list mailing list