diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:10:15 +0000 |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:10:15 +0000 |
commit | 8b9020458a8576459040fce985ab140f0876e2f1 (patch) | |
tree | 63c9ba43ea7673f6662f222b54d8ba93cf480a2d /Lib/os.py | |
parent | 7e7a3ec901be55c868c800d541b5a1622e0ec7fb (diff) | |
download | cpython-git-8b9020458a8576459040fce985ab140f0876e2f1.tar.gz |
#5329: fix os.popen* regression from 2.5: don't execute commands as a sequence
through the shell. also document the correct subprocess replacement for this
case
patch from Jean-Paul Calderone and Jani Hakala
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -666,8 +666,9 @@ if _exists("fork"): import subprocess PIPE = subprocess.PIPE - p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, close_fds=True) + p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring), + bufsize=bufsize, stdin=PIPE, stdout=PIPE, + close_fds=True) return p.stdin, p.stdout __all__.append("popen2") @@ -685,9 +686,9 @@ if _exists("fork"): import subprocess PIPE = subprocess.PIPE - p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, stderr=PIPE, - close_fds=True) + p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring), + bufsize=bufsize, stdin=PIPE, stdout=PIPE, + stderr=PIPE, close_fds=True) return p.stdin, p.stdout, p.stderr __all__.append("popen3") @@ -705,8 +706,8 @@ if _exists("fork"): import subprocess PIPE = subprocess.PIPE - p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, + p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring), + bufsize=bufsize, stdin=PIPE, stdout=PIPE, stderr=subprocess.STDOUT, close_fds=True) return p.stdin, p.stdout __all__.append("popen4") |