[issue1475] test_popen fails when the directory contains a space
Joseph Armbruster
report at bugs.python.org
Tue Nov 20 13:11:15 CET 2007
Joseph Armbruster added the comment:
I believe the issue lies with the cmd command line parameters and
insufficient quoting:
Currently, if this string is passed into CreateProcess as args, the call
will fail:
C:\WINDOWS\System32\cmd.exe /c "C:\Documents and
Settings\joe\Desktop\Development\Python3k\dev\pcbuild9\python.exe" -c
"import sys
; print(sys.argv)" foo bar
For sanity, when I try to execute this from a command prompt manually, I
noticed this behavior:
C:\Documents and Settings\joe>C:\WINDOWS\System32\cmd.exe /c
"C:\Documents and Settings\joe\Desktop\Development\Python3k\dev\pcbui
ld9\python.exe" -c "import sys; print(sys.argv)" foo bar
'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.
I read through cmd.exe and it is has this note:
"""
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
1. If all of the following conditions are met, then quote characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
"""
I believe args falls under section 2.
----------
nosy: +JosephArmbruster
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1475>
__________________________________
More information about the Python-bugs-list
mailing list