[issue8987] Distutils doesn't quote Windows command lines properly

Chris Hogan report at bugs.python.org
Tue Aug 18 20:42:06 CEST 2015


Chris Hogan added the comment:

At Intel, we've run into problems with external modules giving paths to _nt_quote_args that contain trailing backslashes, which escapes the final quote and breaks the command.  This fix takes care of special characters, trailing backslashes, and embedded quotes as in Matt's example.  I've also added unit tests for these cases, as well as a high level test that builds an extension and defines some macros that contain quotes and special characters. 

setup.py - Includes a library directory with a trailing backslash. I compiled a simple library, test_module.lib, and put it in that directory to test the linking.  This fails without my fix.  The macro definitions also fail without this fix.

testmodule.c - A simple C extension.  It just makes sure everything worked and returns the string "Success!"

As for current workarounds in setup scripts, I know numpy uses their own distutils.  They wrote a quote_args() function that they use instead of _nt_quote_args(). It checks for spaces, but only if the argument isn't already quoted.  It doesn't account for other special characters or trailing backslashes.

----------
nosy: +christopher.hogan
Added file: http://bugs.python.org/file40204/quote-args.patch

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


More information about the Python-bugs-list mailing list