Skip to content

Commit

Permalink
Another python2.6 fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Sep 11, 2015
1 parent 65adf6b commit 671d752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'))

Expand Down
4 changes: 4 additions & 0 deletions dulwich/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 671d752

Please sign in to comment.