summaryrefslogtreecommitdiff
path: root/pexpect/pty_spawn.py
diff options
context:
space:
mode:
authorMartin Packman <martin.packman@canonical.com>2016-05-13 18:12:25 +0000
committerMartin Packman <martin.packman@canonical.com>2016-05-13 18:34:09 +0000
commite5eb99c9bc9e19241c3d42e78fcc91d088b84251 (patch)
tree486821a4bc402b94261b50698b6fde6de5d016c6 /pexpect/pty_spawn.py
parent3ed8d66ffb12863bc4a55a4b5dab7fca7ce9a9cc (diff)
downloadpexpect-git-e5eb99c9bc9e19241c3d42e78fcc91d088b84251.tar.gz
Use PATH from env argument to pexpect.spawn
Currently pexpect.spawn takes an env argument along the lines of subprocess.Popen but fails to use PATH from that env when finding the binary to run. The result when running a binary not on the PATH of the parent process is pexpect will raise an exception, or worse, find a different binary with the same name. This change passes the env from spawn into the which function so the correct PATH is searched and adds test coverage.
Diffstat (limited to 'pexpect/pty_spawn.py')
-rw-r--r--pexpect/pty_spawn.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 3518cc1..e5b5814 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -266,7 +266,7 @@ class spawn(SpawnBase):
self.args.insert(0, command)
self.command = command
- command_with_path = which(self.command)
+ command_with_path = which(self.command, env=self.env)
if command_with_path is None:
raise ExceptionPexpect('The command was not found or was not ' +
'executable: %s.' % self.command)