Message 123150 - Python tracker (original) (raw)

My idea is simply using Popen with appropriate args for stdout and stderr instead of using a shell command with redirections:

--- Lib/subprocess.py (révision 86943) +++ Lib/subprocess.py (copie de travail) @@ -560,11 +560,7 @@ return ''.join(result)

-# Various tools for executing commands and looking at their output and status. -# -# NB This only works (and is only relevant) for UNIX.

-def getstatusoutput(cmd): +def getstatusoutput(cmd, shell=True): """Return (status, output) of executing cmd in a shell.

 Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple

@@ -581,14 +577,21 @@ >>> subprocess.getstatusoutput('/bin/junk') (256, 'sh: /bin/junk: not found') """

(The new “shell” argument is icing on the cake, allowing us to later support a list as cmd argument like Popen does.)