8000 fixed support of python3 · popravich/msgpack-python@11a3b15 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11a3b15

Browse files
committed
fixed support of python3
1 parent 48ca2d7 commit 11a3b15

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

msgpack/fallback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def feed(self, next_bytes):
194194
if isinstance(next_bytes, array.array):
195195
next_bytes = next_bytes.tostring()
196196
elif isinstance(next_bytes, bytearray):
197-
next_bytes = str(next_bytes)
197+
next_bytes = (bytes if PY3 else str)(next_bytes)
198198
assert self._fb_feeding
199199
if self._fb_buf_n + len(next_bytes) > self._max_buffer_size:
200200
raise BufferFull

test/test_buffer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# coding: utf-8
33

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

67

78
def test_unpack_buffer():
@@ -16,5 +17,7 @@ def test_unpack_bytearray():
1617
buf = bytearray(packb(('foo', 'bar')))
1718
obj = unpackb(buf, use_list=1)
1819
assert [b'foo', b'bar'] == obj
19-
assert all(type(s)==str for s in obj)
20+
expected_type = bytes if sys.version_info[0] == 3 else str
21+
assert all(type(s)==expected_type for s in obj)
22+
2023

0 commit comments

Comments
 (0)
0