From 6fccbea61195182fe9d46a48daa2e11677a1e7c2 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 21 Jan 2024 22:29:51 +0200 Subject: [PATCH 1/2] gh-111803: Make test_deep_nesting from test_plistlib more strict (GH-114026) It is no longer silently passed if RecursionError was raised for low recursion depth. (cherry picked from commit db1c18eb6220653290a3ba9ebbe1df44394a3f19) Co-authored-by: Serhiy Storchaka --- Lib/test/test_plistlib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index b08ababa341cfe..e1e2feb5990dd1 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -908,12 +908,12 @@ def test_cycles(self): self.assertIs(b['x'], b) def test_deep_nesting(self): - for N in [300, 100000]: + for N in [50, 300, 100_000]: chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)] try: result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4) except RecursionError: - pass + self.assertGreater(N, sys.getrecursionlimit()) else: for i in range(N): self.assertIsInstance(result, list) From a5a39bdb735a25444dd1fa430bfd41f8f5e4b82f Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 22 Jan 2024 11:11:34 +0200 Subject: [PATCH 2/2] Fix test on WASI. --- Lib/test/test_plistlib.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index e1e2feb5990dd1..3f10f16d71996d 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -908,12 +908,13 @@ def test_cycles(self): self.assertIs(b['x'], b) def test_deep_nesting(self): - for N in [50, 300, 100_000]: + tests = [50, 100_000] if support.is_wasi else [50, 300, 100_000] + for N in tests: chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)] try: result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4) except RecursionError: - self.assertGreater(N, sys.getrecursionlimit()) + self.assertGreater(N, sys.getrecursionlimit()//2) else: for i in range(N): self.assertIsInstance(result, list)