diff options
author | INADA Naoki <inada-n@klab.com> | 2013-02-22 17:41:52 +0900 |
---|---|---|
committer | INADA Naoki <inada-n@klab.com> | 2013-02-22 17:41:52 +0900 |
commit | f0fd90a759f07bccfd36e4f9eac8c4b545fd47a4 (patch) | |
tree | dc035064959c80a75f7499917580e46ddbe21b0c /msgpack | |
parent | d766820421c9c67972f899cf6333fbb00e595162 (diff) | |
download | msgpack-python-f0fd90a759f07bccfd36e4f9eac8c4b545fd47a4.tar.gz |
Fix exception incompatibility.
Diffstat (limited to 'msgpack')
-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 |