summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2015-10-06 11:30:10 +0100
committerThomas Kluyver <takowl@gmail.com>2015-10-06 11:30:10 +0100
commitfa5ece24786d659e0bcd8423d66cbaa51b3d8d6c (patch)
treeade481c715b91dcd8278a1052c2b43006102a3e5
parent9708d08b1b386ac78702ece6588e9403ef454e67 (diff)
downloadpexpect-git-fa5ece24786d659e0bcd8423d66cbaa51b3d8d6c.tar.gz
Encode command line args for unicode-mode spawn
Attempt to address gh-272
-rw-r--r--pexpect/pty_spawn.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 1d9554b..7fc27fe 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -285,6 +285,11 @@ class spawn(SpawnBase):
if dimensions is not None:
kwargs['dimensions'] = dimensions
+ if self.encoding is not None:
+ # Encode command line using the specified encoding
+ self.args = [a if isinstance(a, bytes) else a.encode(self.encoding)
+ for a in self.args]
+
self.ptyproc = ptyprocess.PtyProcess.spawn(self.args, env=self.env,
cwd=self.cwd, **kwargs)