8000 Another shot to pass py3 tests. · devendor/msgpack-python@394b339 · GitHub
[go: up one dir, main page]

Skip to content

Commit 394b339

Browse files
committed
Another shot to pass py3 tests.
1 parent 2baaf7b commit 394b339

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

msgpack/fallback.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ class Unpacker(object):
205205
for o in unpacker:
206206
process(o)
207207
"""
208-
208+
# Some old pythons don't support `self._unpack_from()` `bytearray`.
209+
_unpack_from = staticmethod(
210+
struct.unpack_from if sys.version_info >= (2, 7, 6)
211+
else lambda f,b,o=0: struct.unpack_from(f, b[:o+2].tobytes(),o)
212+
)
213+
209214
def __init__(self, file_like=None, read_size=0, use_list=True, raw=True,
210215
object_hook=None, object_pairs_hook=None, list_hook=None,
211216
encoding=None, unicode_errors=None, max_buffer_size=0,
@@ -231,14 +236,6 @@ def __init__(self, file_like=None, read_size=0, use_list=True, raw=True,
231236
raise TypeError("`file_like.read` must be callable")
232237
self.file_like = file_like
233238
self._feeding = False
234-
# Some old pythons don't support `self._unpack_from()` `bytearray`.
235-
if sys.version_info < (2, 7, 6):
236-
self._unpack_from = staticmethod(
237-
lambda f,b,o=0: struct.unpack_from(f, b[:o+2].tobytes(), o)
238-
)
239-
else:
240-
self._unpack_from = staticmethod(struct.unpack_from)
241-
242239

243240
#: array of bytes fed.
244241
self._buffer = bytearray()

0 commit comments

Comments
 (0)
0