Wolfgang Maier added the comment:

Before I forget again what I've gathered yesterday about this issue, here's a 
summary of the problem:

When the the first element of args or the executable argument of 
subprocess.Popen does not specify an absolute path, the way the executable gets 
discovered is platform-dependent.
On POSIX platforms, if the argument contains a directory part, the executable 
gets looked for relative to the current working directory. If the argument is 
just a basename, the PATH is searched.
On Windows, the executable argument and the first element of args are treated 
in different ways: If the executable is specified through the executable 
argument, it is always looked for relative to the current working directory 
only, but if it's specified through args, it's searched for using 
Windows-specific rules as documented for the underlying CreateProcess function 
(see 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx).

Now, on top of all this, if the cwd argument of Popen is used, then, in Python3 
on POSIX-platforms, the current working directory gets changed to cwd *before* 
the above interpretation happens, i.e., if executable or args[0] contains a 
dirname, the executable is looked for relative to cwd.
On Windows, however, cwd becomes the current working directory of the new 
process, but is *not* used during the executable lookup.

I guess with this being rather complicated it would be nice to have a dedicated 
section explaining the interpretation of relative paths as arguments instead of 
trying to get only the cwd wording right.

----------
components: +Library (Lib)
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15533>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to