diff options
-rw-r--r-- | msgpack/_unpacker.pyx | 4 | ||||
-rw-r--r-- | msgpack/fallback.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/msgpack/_unpacker.pyx b/msgpack/_unpacker.pyx index b83a6e4..aeda02a 100644 --- a/msgpack/_unpacker.pyx +++ b/msgpack/_unpacker.pyx @@ -113,10 +113,8 @@ def unpackb(object packed, object object_hook=None, object list_hook=None, if off < buf_len: raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off)) return obj - elif ret < 0: - raise ValueError("Unpack failed: error = %d" % (ret,)) else: - raise UnpackValueError + raise UnpackValueError("Unpack failed: error = %d" % (ret,)) def unpack(object stream, object object_hook=None, object list_hook=None, diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 8dae9a7..f893e1a 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -102,7 +102,10 @@ def unpackb(packed, object_hook=None, list_hook=None, use_list=True, encoding=encoding, unicode_errors=unicode_errors, object_pairs_hook=object_pairs_hook) unpacker.feed(packed) - ret = unpacker._fb_unpack() + try: + ret = unpacker._fb_unpack() + except OutOfData: + raise UnpackValueError("Data is not enough.") if unpacker._fb_got_extradata(): raise ExtraData(ret, unpacker._fb_get_extradata()) return ret |