diff --git a/paramiko/ber.py b/paramiko/ber.py index 4aa788d..a12eed1 100644 --- a/paramiko/ber.py +++ b/paramiko/ber.py @@ -19,6 +19,8 @@ from __future__ import absolute_import from paramiko import util +import six + class BERException (Exception): pass @@ -112,7 +114,7 @@ class BER(object): self.encode_tlv(1, '\xff') else: self.encode_tlv(1, '\x00') - elif (type(x) is int) or (type(x) is long): + elif isinstance(x, six.integer_types): self.encode_tlv(2, util.deflate_long(x)) elif type(x) is str: self.encode_tlv(4, x) diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py index 5b3e642..9384ec0 100644 --- a/paramiko/dsskey.py +++ b/paramiko/dsskey.py @@ -20,6 +20,10 @@ L{DSSKey} """ +import six +if six.PY3: + long = lambda x: int(x) + from Crypto.PublicKey import DSA from Crypto.Hash import SHA diff --git a/paramiko/primes.py b/paramiko/primes.py index 9ebfec1..c6a38b7 100644 --- a/paramiko/primes.py +++ b/paramiko/primes.py @@ -20,6 +20,9 @@ Utility functions for dealing with primes. """ +import six +if six.PY3: + long = lambda x: int(x) from Crypto.Util import number from paramiko import util diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py index 1e2d8f9..c1c4b8d 100644 --- a/paramiko/rsakey.py +++ b/paramiko/rsakey.py @@ -20,6 +20,10 @@ L{RSAKey} """ +import six +if six.PY3: + long = lambda x: int(x) + from Crypto.PublicKey import RSA from Crypto.Hash import SHA, MD5 from Crypto.Cipher import DES3 diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index 86b272a..07f5162 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -20,6 +20,10 @@ Client-mode SFTP support. """ +import six +if six.PY3: + long = lambda x: int(x) + from binascii import hexlify import errno import os diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 2274039..ae3c787 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -20,6 +20,10 @@ L{SFTPFile} """ +import six +if six.PY3: + long = lambda x: int(x) + from binascii import hexlify from collections import deque import socket