mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-03 11:00:55 +00:00
Merge branch '0.2-maint' (fix #39)
This commit is contained in:
commit
833b85f173
4 changed files with 22 additions and 3 deletions
|
|
@ -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(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
|
||||||
if(construct_cb(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
|
if(construct_cb(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
|
||||||
if((count_) == 0) { obj = stack[top].obj; \
|
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; } \
|
goto _push; } \
|
||||||
stack[top].ct = ct_; \
|
stack[top].ct = ct_; \
|
||||||
stack[top].size = count_; \
|
stack[top].size = count_; \
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,28 @@ from msgpack import packb, unpackb
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
class DummyException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_raise_on_find_unsupported_value():
|
def test_raise_on_find_unsupported_value():
|
||||||
assert_raises(TypeError, packb, datetime.datetime.now())
|
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__':
|
if __name__ == '__main__':
|
||||||
from nose import main
|
from nose import main
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ def test_decode_pairs_hook():
|
||||||
|
|
||||||
@raises(ValueError)
|
@raises(ValueError)
|
||||||
def test_only_one_obj_hook():
|
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)
|
@raises(ValueError)
|
||||||
def test_bad_hook():
|
def test_bad_hook():
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ def test_foobar_skip():
|
||||||
assert 1, "ok"
|
assert 1, "ok"
|
||||||
|
|
||||||
def test_maxbuffersize():
|
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 = Unpacker(read_size=3, max_buffer_size=3, use_list=1)
|
||||||
unpacker.feed(b'fo')
|
unpacker.feed(b'fo')
|
||||||
nose.tools.assert_raises(BufferFull, unpacker.feed, b'ob')
|
nose.tools.assert_raises(BufferFull, unpacker.feed, b'ob')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue