diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index b004140..b39f447 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -3761,7 +3761,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