Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor
  • Loading branch information
methane committed Aug 5, 2026
commit 58b6fd9faebfed9aa327d3ccf7447487a609c7c2
17 changes: 7 additions & 10 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,16 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None,
use_list, raw, timestamp, strict_map_key, cerr,
max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len)
ret = unpack_construct(&ctx, buf, buf_len, &off)
if ret == 1 and off < buf_len:
# buf may point into a temporary contiguous copy owned by view,
# so the extra data must be copied out before releasing view.
extra = PyBytes_FromStringAndSize(buf+off, buf_len-off)
if ret == 1:
obj = unpack_data(&ctx)
if off < buf_len:
# buf may point into a temporary contiguous copy owned by view,
# so the extra data must be copied out before releasing view.
raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off))
return obj
finally:
PyBuffer_Release(&view);

if ret == 1:
obj = unpack_data(&ctx)
if extra is not None:
raise ExtraData(obj, extra)
return obj

unpack_clear(&ctx)
if ret == 0:
raise ValueError("Unpack failed: incomplete input")
Expand Down