8000 Merge branch 'pr/82' · faerot/msgpack-python@eb3537a · GitHub
[go: up one dir, main page]

Skip to content

Commit eb3537a

Browse files
committed
Merge branch 'pr/82'
2 parents ff263df + 518f886 commit eb3537a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

msgpack/fallback.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def __init__(self, file_like=None, read_size=0, use_list=True,
193193
def feed(self, next_bytes):
194194
if isinstance(next_bytes, array.array):
195195
next_bytes = next_bytes.tostring()
196+
elif isinstance(next_bytes, bytearray):
197+
next_bytes = bytes(next_bytes)
196198
assert self._fb_feeding
197199
if self._fb_buf_n + len(next_bytes) > self._max_buffer_size:
198200
raise BufferFull

test/test_buffer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
# coding: utf-8
33

44
from msgpack import packb, unpackb
5+
import sys
56

67

78
def test_unpack_buffer():
89
from array import array
910
buf = array('b')
10-
buf.fromstring(packb(('foo', 'bar')))
11+
buf.fromstring(packb((b'foo', b'bar')))
1112
obj = unpackb(buf, use_list=1)
1213
assert [b'foo', b'bar'] == obj
1314

15+
16+
def test_unpack_bytearray():
17+
buf = bytearray(packb(('foo', 'bar')))
18+
obj = unpackb(buf, use_list=1)
19+
assert [b'foo', b'bar'] == obj
20+
expected_type = bytes
21+
assert all(type(s) == expected_type for s in obj)

0 commit comments

Comments
 (0)
0