From 671d752b3b0fa081445cf64cde19b92af659f7a3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Sep 2015 00:23:07 +0000 Subject: [PATCH] Another python2.6 fix. --- dulwich/client.py | 11 +++++++---- dulwich/tests/test_client.py | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dulwich/client.py b/dulwich/client.py index 21f13c6e0..9f5e45d24 100644 --- a/dulwich/client.py +++ b/dulwich/client.py @@ -835,8 +835,10 @@ class SubprocessSSHVendor(SSHVendor): """SSH vendor that shells out to the local 'ssh' command.""" def run_command(self, host, command, username=None, port=None): - if type(command) is not list: + if (type(command) is not list or + not all([isinstance(b, bytes) for b in command])): raise TypeError(command) + import subprocess #FIXME: This has no way to deal with passwords.. args = ['ssh', '-x'] @@ -939,7 +941,8 @@ def __init__(self): def run_command(self, host, command, username=None, port=None, progress_stderr=None): - if type(command) is not list: + if (type(command) is not list or + not all([isinstance(b, bytes) for b in command])): raise TypeError(command) # Paramiko needs an explicit port. None is not valid if port is None: @@ -977,8 +980,8 @@ def __init__(self, host, port=None, username=None, *args, **kwargs): def _get_cmd_path(self, cmd): cmd = self.alternative_paths.get(cmd, b'git-' + cmd) - if sys.version == 2: - return [x.decode('ascii') for x in shlex.split(cmd)] + if sys.version_info[0:2] >= (2, 7): + return [b.decode('ascii') for b in shlex.split(cmd)] else: return shlex.split(cmd.decode('ascii')) diff --git a/dulwich/tests/test_client.py b/dulwich/tests/test_client.py index f7f4ad515..924f1eb5b 100644 --- a/dulwich/tests/test_client.py +++ b/dulwich/tests/test_client.py @@ -498,6 +498,10 @@ def __init__(self): self.port = None def run_command(self, host, command, username=None, port=None): + if (type(command) is not list or + not all([isinstance(b, bytes) for b in command])): + raise TypeError(command) + self.host = host self.command = command self.username = username