[docs] [issue15533] subprocess.Popen(cwd) documentation: Posix vs Windows

Gregory P. Smith report at bugs.python.org
Thu Jun 14 13:14:41 EDT 2018

Gregory P. Smith <greg at krypto.org> added the comment:

Thanks for pointing me at this issue Ned.  It sounds like there is a behavior difference between Windows and POSIX systems related to the current directory and/or which process environment is used by the system call that launches the new process to find the executable.

It seems to have existed "forever" in subprocess module API terms, so I don't know if we should reconcile the corner cases when cwd and/or env are supplied to a single cross platform behavior as that could break existing code.  Such a behavior change _could_ be made but be 3.8 specific.  BUT:  If we did that, it becomes a challenge for people writing code that needs to work on multiple Python versions.  Popen growing yet another bool flag parameter to choose the new behavior is possible, but quite ugly (and unusable on multi-python version code).

I think we should start out by living with the difference - document these platform specific corner case behaviors to minimize surprise.

If we want to provide a way for people to have the same behavior on both, we should document a recommended way to do that.  I believe that entails telling people get an absolute path to their executable themselves before launching the subprocess as that should work the same no matter the cwd or environment?


Python tracker <report at bugs.python.org>

More information about the docs mailing list