diff options
author | Sergey Zhuravlev <zhurs@ya.ru> | 2014-02-12 23:09:23 +0400 |
---|---|---|
committer | Sergey Zhuravlev <zhurs@ya.ru> | 2014-02-12 23:09:23 +0400 |
commit | 11a3b1561a07b28a37ac22637f636c4c5ac24c23 (patch) | |
tree | 3c5d37a8083278c2d93f9f57c84d0f400d51757d | |
parent | 48ca2d700d019bfec9abe3242a8eb3073c803951 (diff) | |
download | msgpack-python-11a3b1561a07b28a37ac22637f636c4c5ac24c23.tar.gz |
fixed support of python3
-rw-r--r-- | msgpack/fallback.py | 2 | ||||
-rw-r--r-- | test/test_buffer.py | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 3ef1341..b673222 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -194,7 +194,7 @@ class Unpacker(object): if isinstance(next_bytes, array.array): next_bytes = next_bytes.tostring() elif isinstance(next_bytes, bytearray): - next_bytes = str(next_bytes) + next_bytes = (bytes if PY3 else str)(next_bytes) assert self._fb_feeding if self._fb_buf_n + len(next_bytes) > self._max_buffer_size: raise BufferFull diff --git a/test/test_buffer.py b/test/test_buffer.py index 5ae87ac..7b85e93 100644 --- a/test/test_buffer.py +++ b/test/test_buffer.py @@ -2,6 +2,7 @@ # coding: utf-8 from msgpack import packb, unpackb +import sys def test_unpack_buffer(): @@ -16,5 +17,7 @@ def test_unpack_bytearray(): buf = bytearray(packb(('foo', 'bar'))) obj = unpackb(buf, use_list=1) 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) + |