mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-25 14:44:10 +00:00
Merge branch 'pr/82'
This commit is contained in:
commit
eb3537ab50
2 changed files with 11 additions and 1 deletions
|
|
@ -193,6 +193,8 @@ class Unpacker(object):
|
|||
def feed(self, next_bytes):
|
||||
if isinstance(next_bytes, array.array):
|
||||
next_bytes = next_bytes.tostring()
|
||||
elif isinstance(next_bytes, bytearray):
|
||||
next_bytes = bytes(next_bytes)
|
||||
assert self._fb_feeding
|
||||
if self._fb_buf_n + len(next_bytes) > self._max_buffer_size:
|
||||
raise BufferFull
|
||||
|
|
|
|||
|
|
@ -2,12 +2,20 @@
|
|||
# coding: utf-8
|
||||
|
||||
from msgpack import packb, unpackb
|
||||
import sys
|
||||
|
||||
|
||||
def test_unpack_buffer():
|
||||
from array import array
|
||||
buf = array('b')
|
||||
buf.fromstring(packb(('foo', 'bar')))
|
||||
buf.fromstring(packb((b'foo', b'bar')))
|
||||
obj = unpackb(buf, use_list=1)
|
||||
assert [b'foo', b'bar'] == obj
|
||||
|
||||
|
||||
def test_unpack_bytearray():
|
||||
buf = bytearray(packb(('foo', 'bar')))
|
||||
obj = unpackb(buf, use_list=1)
|
||||
assert [b'foo', b'bar'] == obj
|
||||
expected_type = bytes
|
||||
assert all(type(s) == expected_type for s in obj)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue