summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Krah <stefan@bytereef.org>2010-07-19 14:49:38 (GMT)
committerStefan Krah <stefan@bytereef.org>2010-07-19 14:49:38 (GMT)
commit9ea629cc836682d52eb7da21900ef335a77344c8 (patch)
tree6cdb20c6ec2aa6ade45a6562367c1e53b9a4f3d3
parentd483a1a12b5ab88cc32f140e537fc172cb0c423d (diff)
downloadcpython-9ea629cc836682d52eb7da21900ef335a77344c8.zip
cpython-9ea629cc836682d52eb7da21900ef335a77344c8.tar.gz
cpython-9ea629cc836682d52eb7da21900ef335a77344c8.tar.bz2
Merged revisions 82973 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ........ r82973 | stefan.krah | 2010-07-19 16:41:08 +0200 (Mon, 19 Jul 2010) | 4 lines Issue #9265: Incorrect name passed as arg[0] when shell=True and executable specified. ........
-rw-r--r--Lib/subprocess.py2
-rw-r--r--Lib/test/test_subprocess.py19
2 files changed, 21 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 9b76421..57cdbe8 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1029,6 +1029,8 @@ class Popen(object):
if shell:
args = ["/bin/sh", "-c"] + args
+ if executable:
+ args[0] = executable
if executable is None:
executable = args[0]
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index ed94fe4..e8f39b1 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -613,6 +613,25 @@ class ProcessTestCase(unittest.TestCase):
os.remove(fname)
self.assertEqual(rc, 47)
+ def test_specific_shell(self):
+ # Issue #9265: Incorrect name passed as arg[0].
+ shells = []
+ for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']:
+ for name in ['bash', 'ksh']:
+ sh = os.path.join(prefix, name)
+ if os.path.isfile(sh):
+ shells.append(sh)
+ if not shells: # Will probably work for any shell but csh.
+ self.skipTest("bash or ksh required for this test")
+ sh = '/bin/sh'
+ if os.path.isfile(sh) and not os.path.islink(sh):
+ # Test will fail if /bin/sh is a symlink to csh.
+ shells.append(sh)
+ for sh in shells:
+ p = subprocess.Popen("echo $0", executable=sh, shell=True,
+ stdout=subprocess.PIPE)
+ self.assertEqual(p.stdout.read().strip(), sh)
+
def DISABLED_test_send_signal(self):
p = subprocess.Popen([sys.executable,
"-c", "input()"])