diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-02-11 11:43:45 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-02-11 11:43:45 +0100 |
commit | 9d6147fe85b25c0c67c6806a586d2a8c95ed109c (patch) | |
tree | 3f180bf45ffa3bede161b938ff61f00134074903 /asyncio/base_events.py | |
parent | 08874a324ab15a1179ac1478883b1c3dad0a7c9d (diff) | |
download | trollius-git-9d6147fe85b25c0c67c6806a586d2a8c95ed109c.tar.gz |
Issue #130: Add more checks on subprocess_exec/subprocess_shell parameters
Diffstat (limited to 'asyncio/base_events.py')
-rw-r--r-- | asyncio/base_events.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/asyncio/base_events.py b/asyncio/base_events.py index 9c5241f..7d12042 100644 --- a/asyncio/base_events.py +++ b/asyncio/base_events.py @@ -558,7 +558,7 @@ class BaseEventLoop(events.AbstractEventLoop): stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=True, bufsize=0, **kwargs): - if not isinstance(cmd, str): + if not isinstance(cmd, (bytes, str)): raise ValueError("cmd must be a string") if universal_newlines: raise ValueError("universal_newlines must be False") @@ -572,7 +572,7 @@ class BaseEventLoop(events.AbstractEventLoop): return transport, protocol @tasks.coroutine - def subprocess_exec(self, protocol_factory, *args, stdin=subprocess.PIPE, + def subprocess_exec(self, protocol_factory, program, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=False, bufsize=0, **kwargs): @@ -582,9 +582,15 @@ class BaseEventLoop(events.AbstractEventLoop): raise ValueError("shell must be False") if bufsize != 0: raise ValueError("bufsize must be 0") + popen_args = (program,) + args + for arg in popen_args: + if not isinstance(arg, (str, bytes)): + raise TypeError("program arguments must be " + "a bytes or text string, not %s" + % type(arg).__name__) protocol = protocol_factory() transport = yield from self._make_subprocess_transport( - protocol, args, False, stdin, stdout, stderr, bufsize, **kwargs) + protocol, popen_args, False, stdin, stdout, stderr, bufsize, **kwargs) return transport, protocol def _add_callback(self, handle): |