Skip to content

Commit

Permalink
Merged revisions 82973 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/python/branches/release27-maint

........
  r82973 | stefan.krah | 2010-07-19 16:41:08 +0200 (Mon, 19 Jul 2010) | 4 lines

  Issue python#9265: Incorrect name passed as arg[0] when shell=True
  and executable specified.
........
  • Loading branch information
cloud-tester committed Jul 19, 2010
1 parent d483a1a commit 9ea629c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,

if shell:
args = ["/bin/sh", "-c"] + args
if executable:
args[0] = executable

if executable is None:
executable = args[0]
Expand Down
19 changes: 19 additions & 0 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,25 @@ def test_call_string(self):
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()"])
Expand Down

0 comments on commit 9ea629c

Please sign in to comment.