mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-06-18 21:52:06 +00:00
Change DEFAULT_RECURSE_LIMIT from 511 to 1024 and add nest_limit test
Agent-Logs-Url: https://github.com/msgpack/msgpack-python/sessions/d5bc8a6a-e14e-4de3-b55f-4206dc3ca170 Co-authored-by: methane <199592+methane@users.noreply.github.com>
This commit is contained in:
parent
8bdc6c246a
commit
3e1ab43171
3 changed files with 20 additions and 2 deletions
|
|
@ -38,7 +38,7 @@ cdef extern from "pack.h":
|
|||
int msgpack_pack_timestamp(msgpack_packer* x, long long seconds, unsigned long nanoseconds) except -1
|
||||
|
||||
|
||||
cdef int DEFAULT_RECURSE_LIMIT=511
|
||||
cdef int DEFAULT_RECURSE_LIMIT=1024
|
||||
cdef long long ITEM_LIMIT = (2**32)-1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ TYPE_RAW = 3
|
|||
TYPE_BIN = 4
|
||||
TYPE_EXT = 5
|
||||
|
||||
DEFAULT_RECURSE_LIMIT = 511
|
||||
DEFAULT_RECURSE_LIMIT = 1024
|
||||
|
||||
|
||||
def _check_type_strict(obj, t, type=type, tuple=tuple):
|
||||
|
|
|
|||
|
|
@ -153,6 +153,24 @@ def test_auto_max_array_len():
|
|||
unpacker.unpack()
|
||||
|
||||
|
||||
def test_nest_limit_1024():
|
||||
import sys
|
||||
|
||||
# Build a list nested 1024 levels deep
|
||||
d = None
|
||||
for _ in range(1024):
|
||||
d = [d]
|
||||
|
||||
# Temporarily raise Python's recursion limit so packing 1024 levels succeeds
|
||||
old_limit = sys.getrecursionlimit()
|
||||
sys.setrecursionlimit(max(old_limit, 10000))
|
||||
try:
|
||||
packed = packb(d)
|
||||
assert unpackb(packed) == d
|
||||
finally:
|
||||
sys.setrecursionlimit(old_limit)
|
||||
|
||||
|
||||
def test_auto_max_map_len():
|
||||
# len(packed) == 6 -> max_map_len == 3
|
||||
packed = b"\xde\x00\x04zzz"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue