[issue17023] Subprocess does not find executable on Windows if it is PATH with quotes

Eryk Sun report at bugs.python.org
Wed Mar 18 07:19:02 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

Why are new versions getting added to an issue that was closed 5 years ago? 

That said, I'd like to clarify that this was not and is not a bug. It happens that the CMD shell strips quotes out, but that doesn't make it valid. PATH in Windows is delimited by semicolons, not spaces, so paths with spaces should never be quoted. In particular, WINAPI SearchPathW, which CreateProcessW calls, leaves quotes in the directory name when testing whether a file is in the directory.

Also, the conclusion that Linux doesn't suffer from this problem is incorrect. The shell command that was used actually strips the quotes out as part of command-line pre-processing, i.e. `PATH=$PATH:"test"` results in the same PATH value as `PATH=$PATH:test`. But it will fail to find "script.sh" if you escape the quotes to make the shell add them literally to PATH, e.g. `PATH=$PATH:\"test\"`.

----------
nosy: +eryksun
resolution: wont fix -> not a bug

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17023>
_______________________________________


More information about the Python-bugs-list mailing list