Eryk Sun <eryk...@gmail.com> added the comment:

The Popen() docs begin by explaining that it has "os.execvp()-like" behavior in 
POSIX and uses CreateProcess() in Windows. Personally, I do not think it's 
proper for Python's documentation to discuss details of  how CreateProcess() 
handles lpCommandLine (args), lpApplicationName (executable), 
lpCurrentDirectory (cwd), and lpEnvironment (env). So maybe all this needs is 
to clearly map Popen() parameters to the corresponding CreateProcess() 
parameters.

If Popen() implements a parameter on its own, then it makes sense to me to 
document the behavior. For example, in POSIX the behavior of `cwd` is 
implemented by Popen(), and documented as follows:

    In particular, the function looks for executable (or for the first 
    item in args) relative to cwd if the executable path is a relative
    path.

This claim is not always true in POSIX since a base filename without a slash in 
it, which is a relative path, is not searched for in the current directory 
unless "." is in PATH. But the main problem with the above sentence is the lack 
of a disclaimer that it only applies to POSIX. In Windows, `cwd` is passed 
through directly as the lpCurrentDirectory of CreateProcess(). This parameter 
sets the working directory of the child process and has nothing to do with 
searching for an executable parsed out of lpCommandLine or resolving a relative 
path in lpApplicationName. It may affect the result with shell=True, but even 
in that case there are caveats. Regardless, Python doesn't do anything with 
`cwd` in Windows except pass it to CreateProcess(), so the cwd -> 
lpCurrentDirectory parameter mapping is all there is to document.

----------
status: languishing -> open
type: behavior -> enhancement
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7, Python 3.5, Python 
3.6, Python 3.7

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

Reply via email to