Skip to content

Commit 8dd8a0d

Browse files
committed
Little fix to newint.from_bytes()
1 parent 1049e01 commit 8dd8a0d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

future/types/newint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import struct
1111

1212
from future.types.newbytes import newbytes
13-
from future.utils import PY3, isint, istext, isbytes, with_metaclass
13+
from future.utils import PY3, isint, istext, isbytes, with_metaclass, native
1414

1515

1616
if PY3:
@@ -337,7 +337,9 @@ def from_bytes(cls, bytes, byteorder='big', signed=False):
337337
b = bytes if byteorder == 'big' else bytes[::-1]
338338
if len(b) == 0:
339339
b = b'\x00'
340-
num = int(b.encode('hex'), 16)
340+
# The encode() method has been disabled by newbytes, but Py2's
341+
# str has it:
342+
num = int(native(b).encode('hex'), 16)
341343
return cls(num)
342344

343345

0 commit comments

Comments
 (0)