diff --git a/paramiko/_winapi.py b/paramiko/_winapi.py index ab90c4a..b45a5d5 100644 --- a/paramiko/_winapi.py +++ b/paramiko/_winapi.py @@ -118,7 +118,7 @@ class MemoryMap(object): FILE_MAP_WRITE = 0x2 filemap = ctypes.windll.kernel32.CreateFileMappingW( INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length, - unicode(self.name)) + builtins.unicode(self.name)) handle_nonzero_success(filemap) if filemap == INVALID_HANDLE_VALUE: raise Exception("Failed to create file mapping") diff --git a/paramiko/agent.py b/paramiko/agent.py index d4ff703..920ea7f 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -215,7 +215,7 @@ class AgentClientProxy(object): # probably a dangling env var: the ssh agent is gone return elif sys.platform == 'win32': - import win_pageant + from paramiko import win_pageant if win_pageant.can_talk_to_agent(): conn = win_pageant.PageantConnection() else: @@ -334,7 +334,7 @@ class Agent(AgentSSH): # probably a dangling env var: the ssh agent is gone return elif sys.platform == 'win32': - import win_pageant + from paramiko import win_pageant if win_pageant.can_talk_to_agent(): conn = win_pageant.PageantConnection() else: diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index c7bb58b..a935c70 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -25,6 +25,7 @@ import weakref # this helps freezing utils import encodings.utf_8 +import six from paramiko.common import * from paramiko import util @@ -198,7 +199,7 @@ class AuthHandler (object): if self.auth_method == 'password': m.add_boolean(False) password = self.password - if isinstance(password, unicode): + if isinstance(password, six.text_type): password = password.encode('UTF-8') m.add_string(password) elif self.auth_method == 'publickey': diff --git a/paramiko/client.py b/paramiko/client.py index 002c04c..760edf5 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -25,6 +25,7 @@ import getpass import os import socket import warnings +import six from paramiko.agent import Agent from paramiko.common import * @@ -335,7 +336,7 @@ class SSHClient (object): if key_filename is None: key_filenames = [] - elif isinstance(key_filename, (str, unicode)): + elif isinstance(key_filename, (six.binary_type, six.text_type)): key_filenames = [ key_filename ] else: key_filenames = key_filename diff --git a/paramiko/server.py b/paramiko/server.py index df1f7fc..1428929 100644 --- a/paramiko/server.py +++ b/paramiko/server.py @@ -21,6 +21,8 @@ L{ServerInterface} is an interface to override for server support. """ import threading +import six + from paramiko.common import * from paramiko import util @@ -48,7 +50,7 @@ class InteractiveQuery (object): self.instructions = instructions self.prompts = [] for x in prompts: - if (type(x) is str) or (type(x) is unicode): + if isinstance(x, (six.binary_type, six.text_type)): self.add_prompt(x) else: self.add_prompt(x[0], x[1]) diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index 07f5162..18bc39d 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -373,7 +373,7 @@ class SFTPClient (BaseSFTP): """ dest = self._adjust_cwd(dest) self._log(DEBUG, 'symlink(%r, %r)' % (source, dest)) - if type(source) is unicode: + if isinstance(source, six.text_type): source = source.encode('utf-8') self._request(CMD_SYMLINK, source, dest) @@ -774,7 +774,7 @@ class SFTPClient (BaseSFTP): Return an adjusted path if we're emulating a "current working directory" for the server. """ - if type(path) is unicode: + if isinstance(path, six.text_type): path = path.encode('utf-8') if self._cwd is None: return path diff --git a/paramiko/transport.py b/paramiko/transport.py index a561120..70773d7 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -280,7 +280,7 @@ class Transport (threading.Thread): @param sock: a socket or socket-like object to create the session over. @type sock: socket """ - if isinstance(sock, (str, unicode)): + if isinstance(sock, (six.binary_type, six.text_type)): # convert "host:port" into (host, port) hl = sock.split(':', 1) if len(hl) == 1: