mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-06-27 19:20:50 +00:00
Raise DEFAULT_RECURSE_LIMIT from 511 to 1024 (#676)
This commit is contained in:
parent
cd8137093a
commit
4b2749cdff
3 changed files with 26 additions and 2 deletions
|
|
@ -153,6 +153,30 @@ 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)
|
||||
result = unpackb(packed)
|
||||
finally:
|
||||
sys.setrecursionlimit(old_limit)
|
||||
|
||||
# Verify structure iteratively to avoid hitting C-level recursion limit in ==
|
||||
for _ in range(1024):
|
||||
assert isinstance(result, list) and len(result) == 1
|
||||
result = result[0]
|
||||
assert result is None
|
||||
|
||||
|
||||
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