8000 Fix exception incompatibility. · peter80/msgpack-python@f0fd90a · GitHub
[go: up one dir, main page]

Skip to content

Commit f0fd90a

committed
Fix exception incompatibility.
1 parent d766820 commit f0fd90a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

msgpack/_unpacker.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
113113
if off < buf_len:
114114
raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off))
115115
return obj
116-
elif ret < 0:
117-
raise ValueError("Unpack failed: error = %d" % (ret,))
118116
else:
119-
raise UnpackValueError
117+
raise UnpackValueError("Unpack failed: error = %d" % (ret,))
120118

121119

122120
def unpack(object stream, object object_hook=None, object list_hook=None,

msgpack/fallback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def unpackb(packed, object_hook=None, list_hook=None, use_list=True,
102102
encoding=encoding, unicode_errors=unicode_errors,
103103
object_pairs_hook=object_pairs_hook)
104104
unpacker.feed(packed)
105 6272 -
ret = unpacker._fb_unpack()
105+
try:
106+
ret = unpacker._fb_unpack()
107+
except OutOfData:
108+
raise UnpackValueError("Data is not enough.")
106109
if unpacker._fb_got_extradata():
107110
raise ExtraData(ret, unpacker._fb_get_extradata())
108111
return ret

0 commit comments

Comments
 (0)
0