Skip to content

Commit 58b6fd9

Browse files
committed
refactor
1 parent ea4bd9d commit 58b6fd9

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

msgpack/_unpacker.pyx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,16 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None,
191191
use_list, raw, timestamp, strict_map_key, cerr,
192192
max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len)
193193
ret = unpack_construct(&ctx, buf, buf_len, &off)
194-
if ret == 1 and off < buf_len:
195-
# buf may point into a temporary contiguous copy owned by view,
196-
# so the extra data must be copied out before releasing view.
197-
extra = PyBytes_FromStringAndSize(buf+off, buf_len-off)
194+
if ret == 1:
195+
obj = unpack_data(&ctx)
196+
if off < buf_len:
197+
# buf may point into a temporary contiguous copy owned by view,
198+
# so the extra data must be copied out before releasing view.
199+
raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off))
200+
return obj
198201
finally:
199202
PyBuffer_Release(&view);
200203

201-
if ret == 1:
202-
obj = unpack_data(&ctx)
203-
if extra is not None:
204-
raise ExtraData(obj, extra)
205-
return obj
206-
207204
unpack_clear(&ctx)
208205
if ret == 0:
209206
raise ValueError("Unpack failed: incomplete input")

0 commit comments

Comments
 (0)