mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-22 13:23:17 +00:00
fixed support of python3
This commit is contained in:
parent
48ca2d700d
commit
11a3b1561a
2 changed files with 5 additions and 2 deletions
|
@ -194,7 +194,7 @@ class Unpacker(object):
|
||||||
if isinstance(next_bytes, array.array):
|
if isinstance(next_bytes, array.array):
|
||||||
next_bytes = next_bytes.tostring()
|
next_bytes = next_bytes.tostring()
|
||||||
elif isinstance(next_bytes, bytearray):
|
elif isinstance(next_bytes, bytearray):
|
||||||
next_bytes = str(next_bytes)
|
next_bytes = (bytes if PY3 else str)(next_bytes)
|
||||||
assert self._fb_feeding
|
assert self._fb_feeding
|
||||||
if self._fb_buf_n + len(next_bytes) > self._max_buffer_size:
|
if self._fb_buf_n + len(next_bytes) > self._max_buffer_size:
|
||||||
raise BufferFull
|
raise BufferFull
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from msgpack import packb, unpackb
|
from msgpack import packb, unpackb
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def test_unpack_buffer():
|
def test_unpack_buffer():
|
||||||
|
@ -16,5 +17,7 @@ def test_unpack_bytearray():
|
||||||
buf = bytearray(packb(('foo', 'bar')))
|
buf = bytearray(packb(('foo', 'bar')))
|
||||||
obj = unpackb(buf, use_list=1)
|
obj = unpackb(buf, use_list=1)
|
||||||
assert [b'foo', b'bar'] == obj
|
assert [b'foo', b'bar'] == obj
|
||||||
assert all(type(s)==str for s in obj)
|
expected_type = bytes if sys.version_info[0] == 3 else str
|
||||||
|
assert all(type(s)==expected_type for s in obj)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue