[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True

Chris Rebert report at bugs.python.org
Sun Apr 1 08:58:09 CEST 2012


Chris Rebert <pybugs at rebertia.com> added the comment:

> The reason I'm not a fan is the fact that, with "shell=True", you can use the *executable* argument to Popen to select a non-default shell. At that point, passing a list can make sense, even if it isn't useful for the default shell.

Modulo Windows, at that point, why not just run the shell explicitly (i.e. shell=False, args=['my_sh', ...])? Also, a '-c' argument will be forcibly prepended to the passed-in `args` in your case, which may frustrate such use-cases.

> For the other way around, passing a string with "shell=False" can be a straightforward way to launch GUI applications from a script.

And they may need to eventually pass it (an) argument(s), and when that happens, cue confusion! There's a reason the `subprocess` docs feature the not-strictly-necessary clause "[a str `args` w/ shell=False] will only work if the program is being given no arguments". The distinction regularly trips/tripped users up.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7839>
_______________________________________


More information about the Python-bugs-list mailing list