[issue18649] list2cmdline function in subprocess module handles \" sequence wrong

R. David Murray report at bugs.python.org
Sun Aug 4 18:12:55 CEST 2013


R. David Murray added the comment:

This is a only a duplicate of issue 1300 in the sense that that issue points out that list2cmdline has nothing to do with passing/quoting strings for cmd.exe.

list2cmdline is an internal function of the subprocess module.  Its docstring documents the MS C quoting rules, *not* the input quoting rules.  So its output is correct according to its doc string.  If you pass ["test.bat", r'\"1|2\"'] to Popen using Richard's version of test.bat, you should get

  \"1|2\"

as the output, which would be correct, since that is what you passed in as the argument to test.bat in the Popen call.  The point is that the arguments specified in the list (shell=False) Popen call is supposed to be exactly what arguments get passed to the called program, and list2cmdline takes care of the MS C quoting to make that happen. (I don't use Windows much, so it is a bit of a pain for me to confirm the above example, but I'm nearly certain it will work as I say, modulo whatever quoting rule 'echo' uses for output.)

----------
components: +Benchmarks -Library (Lib)
resolution:  -> invalid
status: open -> closed

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


More information about the Python-bugs-list mailing list