From 34385afbbd525c104d9b56f299455f35c3741549 Mon Sep 17 00:00:00 2001 From: Christian Plesner Hansen Date: Wed, 15 Feb 2017 12:02:41 +0100 Subject: [PATCH] Pass options correctly through from_bytes to FlatArrayMessageReader --- capnp/lib/capnp.pyx | 4 +++- test/test_serialization.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index 284bd7c..ae27c4b 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -3783,7 +3783,9 @@ cdef class _FlatArrayMessageReader(_MessageReader): else: self._object_to_pin = buf - self.thisptr = new schema_cpp.FlatArrayMessageReader(schema_cpp.WordArrayPtr(ptr, sz//8)) + self.thisptr = new schema_cpp.FlatArrayMessageReader( + schema_cpp.WordArrayPtr(ptr, sz//8), + opts) def __dealloc__(self): del self.thisptr diff --git a/test/test_serialization.py b/test/test_serialization.py index ebead7e..66a1d88 100644 --- a/test/test_serialization.py +++ b/test/test_serialization.py @@ -168,3 +168,26 @@ def test_pickle(all_types): msg2 = pickle.loads(data) test_regression.check_all_types(msg2) + +def test_from_bytes_traversal_limit(all_types): + size = 1024 + bld = all_types.TestAllTypes.new_message() + bld.init("structList", size) + data = bld.to_bytes() + + msg = all_types.TestAllTypes.from_bytes(data, + traversal_limit_in_words=2**62) + for i in range(0, size): + assert msg.structList[i].uInt8Field == 0 + + +def test_from_bytes_packed_traversal_limit(all_types): + size = 1024 + bld = all_types.TestAllTypes.new_message() + bld.init("structList", size) + data = bld.to_bytes_packed() + + msg = all_types.TestAllTypes.from_bytes_packed(data, + traversal_limit_in_words=2**62) + for i in range(0, size): + assert msg.structList[i].uInt8Field == 0