Merged revisions 75143 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75143 | philip.jenvey | 2009-09-29 12:10:15 -0700 (Tue, 29 Sep 2009) | 5 lines

  #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
........
diff --git a/Lib/os.py b/Lib/os.py
index abbadc4..94476a3 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -670,8 +670,9 @@
 
             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")
 
@@ -689,9 +690,9 @@
 
             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")
 
@@ -709,8 +710,8 @@
 
             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")