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

2020-03-18 Thread Eryk Sun


Eryk Sun  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2020-03-18 Thread Oskar Persson


Change by Oskar Persson :


--
versions: +Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-02-08 Thread Tim Golden

Changes by Tim Golden m...@timgolden.me.uk:


--
resolution:  - wont fix
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17023
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-02-04 Thread Eli_B

Changes by Eli_B eli.boyar...@gmail.com:


--
nosy: +Eli_B

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17023
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-02-04 Thread Tim Golden

Tim Golden added the comment:

Under the covers, subprocess is calling CreateProcess so there's really not 
very much we can do here, short of writing our own PATH-handling.

As a matter of fact, passing shell=True will produce the desired effect. Since 
the only thing this does is to run the process under cmd.exe I assume that 
cmd.exe itself adds some kind of PATH handling of its own.

I recommend closing as won't fix.

--
assignee:  - tim.golden
components: +Windows
nosy: +steve.dower, tim.golden, zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17023
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-07-12 Thread Mark Lawrence

Mark Lawrence added the comment:

@Pekka sorry about the delay in getting back to you.

I can confirm that this is still in issue in 3.4.1 and 3.5.0a0.

--
components: +Library (Lib)
nosy: +BreamoreBoy
type:  - behavior
versions: +Python 2.7, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17023
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-01-24 Thread Pekka Klärck

New submission from Pekka Klärck:

If you add a directory into PATH on Windows so that the directory is in quotes, 
subprocess does not find executables in it. They are found by the operating 
system, though, at least when run on the command prompt.

To reproduce:

C:\python --version
Python 2.7.3
C:\type test\script.bat
@echo off
echo hello
C:\set ORIG=%PATH%
C:\set PATH=%ORIG%;test
C:\script.bat
hello
C:\python -c from subprocess import call; call('script.bat')
hello
C:\set PATH=%ORIG%;test
C:\script.bat
hello
C:\python -c from subprocess import call; call('script.bat')
Traceback (most recent call last):
  File string, line 1, in module
  File C:\Python27\lib\subprocess.py, line 493, in call
return Popen(*popenargs, **kwargs).wait()
  File C:\Python27\lib\subprocess.py, line 679, in __init__
errread, errwrite)
  File C:\Python27\lib\subprocess.py, line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified


I don't think you ever need those quotes, even if the directory would have 
spaces, but it is very confusing that the behavior is different on the command 
prompt and with subprocess. Additionally, Linux does not suffer from this 
problem:

$ python --version
Python 2.7.3
$ cat test/script.sh 
#!/bin/sh
echo hello
$ PATH=$PATH:test script.sh
hello
$ PATH=$PATH:test python -c from subprocess import call; call('script.sh')
hello
$ PATH=$PATH:test script.sh
hello
$ PATH=$PATH:test python -c from subprocess import call; call('script.sh')
hello

--
messages: 180520
nosy: pekka.klarck
priority: normal
severity: normal
status: open
title: Subprocess does not find executable on Windows if it is PATH with quotes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17023
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com