mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-20 04:13:16 +00:00
pack and packb raises ValueError when extra data passed.
This commit is contained in:
parent
4d643894a1
commit
8b2959bc0a
1 changed files with 5 additions and 2 deletions
|
@ -257,7 +257,10 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
|
||||||
ctx.user.list_hook = <PyObject*>list_hook
|
ctx.user.list_hook = <PyObject*>list_hook
|
||||||
ret = template_execute(&ctx, buf, buf_len, &off)
|
ret = template_execute(&ctx, buf, buf_len, &off)
|
||||||
if ret == 1:
|
if ret == 1:
|
||||||
return template_data(&ctx)
|
obj = template_data(&ctx)
|
||||||
|
if off < buf_len:
|
||||||
|
raise ValueError("Extra data.")
|
||||||
|
return obj
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -461,7 +464,7 @@ cdef class Unpacker(object):
|
||||||
if self.file_like is not None:
|
if self.file_like is not None:
|
||||||
self.read_from_file()
|
self.read_from_file()
|
||||||
continue
|
continue
|
||||||
raise StopIteration("No more unpack data.")
|
raise StopIteration("No more data to unpack.")
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unpack failed: error = %d" % (ret,))
|
raise ValueError("Unpack failed: error = %d" % (ret,))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue