summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--msgpack/unpack_template.h2
-rw-r--r--test/test_except.py19
-rw-r--r--test/test_obj.py2
-rw-r--r--test/test_sequnpack.py2
4 files changed, 22 insertions, 3 deletions
diff --git a/msgpack/unpack_template.h b/msgpack/unpack_template.h
index 8a57f0d..83b6918 100644
--- a/msgpack/unpack_template.h
+++ b/msgpack/unpack_template.h
@@ -146,7 +146,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
if(construct_cb(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
if((count_) == 0) { obj = stack[top].obj; \
- construct_cb(func##_end)(user, &obj); \
+ if (construct_cb(func##_end)(user, &obj) < 0) { goto _failed; } \
goto _push; } \
stack[top].ct = ct_; \
stack[top].size = count_; \
diff --git a/test/test_except.py b/test/test_except.py
index ad02cb6..e142dd6 100644
--- a/test/test_except.py
+++ b/test/test_except.py
@@ -6,9 +6,28 @@ from msgpack import packb, unpackb
import datetime
+class DummyException(Exception):
+ pass
+
+
def test_raise_on_find_unsupported_value():
assert_raises(TypeError, packb, datetime.datetime.now())
+
+def test_raise_from_object_hook():
+ def hook(obj):
+ raise DummyException
+ assert_raises(DummyException, unpackb, packb({}), object_hook=hook)
+ assert_raises(DummyException, unpackb, packb({'fizz': 'buzz'}),
+ object_hook=hook)
+ assert_raises(DummyException, unpackb, packb({'fizz': 'buzz'}),
+ object_pairs_hook=hook)
+ assert_raises(DummyException, unpackb, packb({'fizz': {'buzz': 'spam'}}),
+ object_hook=hook)
+ assert_raises(DummyException, unpackb, packb({'fizz': {'buzz': 'spam'}}),
+ object_pairs_hook=hook)
+
+
if __name__ == '__main__':
from nose import main
main()
diff --git a/test/test_obj.py b/test/test_obj.py
index 1d9024b..bfc9ab2 100644
--- a/test/test_obj.py
+++ b/test/test_obj.py
@@ -34,7 +34,7 @@ def test_decode_pairs_hook():
@raises(ValueError)
def test_only_one_obj_hook():
- unpackb(b'', object_hook=lambda x: x, object_pairs_hook=lambda x: x)
+ unpackb(b'', object_hook=lambda x: x, object_pairs_hook=lambda x: x, use_list=1)
@raises(ValueError)
def test_bad_hook():
diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py
index f767726..ca4c8db 100644
--- a/test/test_sequnpack.py
+++ b/test/test_sequnpack.py
@@ -46,7 +46,7 @@ def test_foobar_skip():
assert 1, "ok"
def test_maxbuffersize():
- nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3)
+ nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3, use_list=1)
unpacker = Unpacker(read_size=3, max_buffer_size=3, use_list=1)
unpacker.feed(b'fo')
nose.tools.assert_raises(BufferFull, unpacker.feed, b'ob')