[Python 3]: Workaround for long values in Python 3's unified integer types. paramiko.message not worked around for now.

This commit is contained in:
Dorian 2013-10-24 08:35:38 -04:00
parent 1022eec17a
commit cc2dd9c0f4
6 changed files with 22 additions and 1 deletions

View File

@ -19,6 +19,8 @@
from __future__ import absolute_import from __future__ import absolute_import
from paramiko import util from paramiko import util
import six
class BERException (Exception): class BERException (Exception):
pass pass
@ -112,7 +114,7 @@ class BER(object):
self.encode_tlv(1, '\xff') self.encode_tlv(1, '\xff')
else: else:
self.encode_tlv(1, '\x00') 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)) self.encode_tlv(2, util.deflate_long(x))
elif type(x) is str: elif type(x) is str:
self.encode_tlv(4, x) self.encode_tlv(4, x)

View File

@ -20,6 +20,10 @@
L{DSSKey} L{DSSKey}
""" """
import six
if six.PY3:
long = lambda x: int(x)
from Crypto.PublicKey import DSA from Crypto.PublicKey import DSA
from Crypto.Hash import SHA from Crypto.Hash import SHA

View File

@ -20,6 +20,9 @@
Utility functions for dealing with primes. Utility functions for dealing with primes.
""" """
import six
if six.PY3:
long = lambda x: int(x)
from Crypto.Util import number from Crypto.Util import number
from paramiko import util from paramiko import util

View File

@ -20,6 +20,10 @@
L{RSAKey} L{RSAKey}
""" """
import six
if six.PY3:
long = lambda x: int(x)
from Crypto.PublicKey import RSA from Crypto.PublicKey import RSA
from Crypto.Hash import SHA, MD5 from Crypto.Hash import SHA, MD5
from Crypto.Cipher import DES3 from Crypto.Cipher import DES3

View File

@ -20,6 +20,10 @@
Client-mode SFTP support. Client-mode SFTP support.
""" """
import six
if six.PY3:
long = lambda x: int(x)
from binascii import hexlify from binascii import hexlify
import errno import errno
import os import os

View File

@ -20,6 +20,10 @@
L{SFTPFile} L{SFTPFile}
""" """
import six
if six.PY3:
long = lambda x: int(x)
from binascii import hexlify from binascii import hexlify
from collections import deque from collections import deque
import socket import socket