[Python 3]: Added fix for enabling proper adding of integers under both Python 2 and 3.

This commit is contained in:
Dorian 2013-10-25 17:28:54 -04:00
parent 3c33c763a7
commit 9ffd9efb20
1 changed files with 16 additions and 8 deletions

View File

@ -20,11 +20,15 @@
Implementation of an SSH2 "message".
"""
import struct
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
import six
if six.PY3:
long = lambda x: int(x)
from paramiko import util
@ -277,13 +281,17 @@ class Message (object):
def _add(self, i):
if type(i) is str:
return self.add_string(i)
elif type(i) is int:
elif type(i) in six.integer_types:
if type(i) is int and not six.PY3:
return self.add_int(i)
elif type(i) is long:
else:
if i > long(0xffffffff):
return self.add_mpint(i)
else:
return self.add_int(i)
elif type(i) is bool:
return self.add_boolean(i)
elif type(i) is list: