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.

Author r.david.murray
Recipients barry, christopher.hogan, dstufft, eric.araujo, mgiuca, ncoghlan, r.david.murray, steve.dower, tarek, zach.ware
Date 2015-08-19.21:45:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1440020734.41.0.757891059151.issue8987@psf.upfronthosting.co.za>
In-reply-to
Content
There are two features of this I have questions about.  If I'm understanding correctly, if passed a quoted string you are not re-quoting it, but you are always stripping a trailing slash even if it is inside quotes.

For the first, that seems wrong.  Either we should be quoting the quotes, or we should assume that if passed a string that starts and ends with quotes, that it is already fully quoted, and not change it.

For the second, doesn't that potentially change the semantics of the string passed in?  You can't actually know that the backslash is part of a path, nor can you be sure that a trailing backslash is not significant even if it is a path.  And in fact if there is a backslash before a double quote, arguably that is supposed to be a double quote that doesn't end the string (see point one above).

I tried list2cmdline, and what it does is to backslash escape appropriately, including preserving blackslashes that are in front of double quotes, and does not add surrounding quotes if there are no internal blanks.  I think list2cmdline is correct here (and it has certainly seen a lot of use), and I think we should either replicate its logic or just use it.

Now, subprocess calls CreateProcess, while distutils calls os.spawnv, but my understanding is that the quoting rules are the same (that is, that the CRT's _spawnv ultimately calls CreateProcess with the arguments joined by blanks).  

Since issue 8972 has been resolved by fixing the broken behavior, I think we should just use list2cmdline.  We could leave _nt_quote_args alone and replace the call to it in _spawn_nt with:

  cmd = [list2cmdline([arg]) for arg in cmd]

or we could put the fix in _nt_quote_args.  The backward compatibility calculus is...not obvious :(
History
Date User Action Args
2015-08-19 21:45:34r.david.murraysetrecipients: + r.david.murray, barry, ncoghlan, tarek, eric.araujo, mgiuca, zach.ware, steve.dower, dstufft, christopher.hogan
2015-08-19 21:45:34r.david.murraysetmessageid: <1440020734.41.0.757891059151.issue8987@psf.upfronthosting.co.za>
2015-08-19 21:45:34r.david.murraylinkissue8987 messages
2015-08-19 21:45:33r.david.murraycreate