[docs] [issue8557] subprocess PATH semantics

R. David Murray report at bugs.python.org
Thu Apr 29 17:49:46 CEST 2010

R. David Murray <rdmurray at bitdance.com> added the comment:

Changing the default value of shell is not an option anyway.

The behavior you describe is exactly what one should expect: the environment in which the executable is located is the environment of the process calling Popen, not the environment passed to Popen.  The environment passed to Popen is the environment in which the subprocess executes.  When using shell=True, this is the environment in which the shell executes, and the *shell* then looks up the executable in that new environment.  As far as I know this behavior is the same on both Windows and Unix, and thus is not a portability issue.  (How the shell works can be a portability issue, though.)

I'm not sure that this needs to be documented explicitly, as it is a logical consequence of how subprocesses work, but if you want to suggest a doc update I'll take a look at it.

I suspect your Unix example is about the fragility of the rules for computing sys.executable (there's an issue in the tracker about that...you may get a different result on trunk), but I haven't checked it.

nosy: +r.david.murray
title: subprocess portability issue -> subprocess PATH semantics

Python tracker <report at bugs.python.org>

More information about the docs mailing list