Author wolma
Recipients asvetlov, chris.jerdonek, cvrebert, docs@python, ned.deily, pepalogik, python-dev, wolma
Date 2016-11-25.08:55:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480064154.53.0.156012673177.issue15533@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-11-25 08:55:54wolmasetrecipients: + wolma, ned.deily, cvrebert, asvetlov, chris.jerdonek, docs@python, python-dev, pepalogik
2016-11-25 08:55:54wolmasetmessageid: <1480064154.53.0.156012673177.issue15533@psf.upfronthosting.co.za>
2016-11-25 08:55:54wolmalinkissue15533 messages
2016-11-25 08:55:53wolmacreate