diff options
author | Thomas Kluyver <thomas@kluyver.me.uk> | 2017-07-25 10:24:25 +0100 |
---|---|---|
committer | Thomas Kluyver <thomas@kluyver.me.uk> | 2017-07-25 10:24:25 +0100 |
commit | 6d5811aef8ec50debe4bd7abf3964a14cf04688a (patch) | |
tree | 9e819c6e1ac2aa404c74528b4465cfbab4d3b266 | |
parent | 94f91bd8c56f5e277a9859129ee9260658fd170a (diff) | |
download | pexpect-git-6d5811aef8ec50debe4bd7abf3964a14cf04688a.tar.gz |
Only pass strings to shlex
Avoid passing None, which causes it to read from stdin.
Closes gh-433
-rw-r--r-- | pexpect/popen_spawn.py | 3 | ||||
-rw-r--r-- | pexpect/utils.py | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/pexpect/popen_spawn.py b/pexpect/popen_spawn.py index 600ac92..c9d4738 100644 --- a/pexpect/popen_spawn.py +++ b/pexpect/popen_spawn.py @@ -15,6 +15,7 @@ except ImportError: from .spawnbase import SpawnBase, PY3 from .exceptions import EOF +from .utils import string_types class PopenSpawn(SpawnBase): if PY3: @@ -39,7 +40,7 @@ class PopenSpawn(SpawnBase): kwargs['startupinfo'] = startupinfo kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP - if not isinstance(cmd, (list, tuple)): + if isinstance(cmd, string_types): cmd = shlex.split(cmd) self.proc = subprocess.Popen(cmd, **kwargs) diff --git a/pexpect/utils.py b/pexpect/utils.py index ae0fe9d..bafc280 100644 --- a/pexpect/utils.py +++ b/pexpect/utils.py @@ -11,6 +11,11 @@ except NameError: # Alias Python2 exception to Python3 InterruptedError = select.error +if sys.version_info[0] >= 3: + string_types = (str,) +else: + string_types = (unicode, str) + def is_executable_file(path): """Checks that path is an executable regular file, or a symlink towards one. |