From 06dc5ac7489f23e33f88a2c6b46a6eacc25f890e Mon Sep 17 00:00:00 2001 From: Ahmed Semih Ozmekik Date: Thu, 12 Nov 2026 08:39:56 +0300 Subject: [PATCH] gh-158314: Fix test_parameters_deep_recursion on 32-bit ARM _Py_make_parameters() uses only 48 bytes of C stack per level in a debug build on 32-bit ARM, so 150_000 nested lists fit in the 8 MiB stack of run_with_limited_c_stack() and no RecursionError is raised. Nest 500_000 levels, as other tests with small C frames do. --- Lib/test/test_typing.py | 8 +++++--- .../Tests/2026-11-12-05-39-56.gh-issue-158314.SZiMPV.rst | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-11-12-05-39-56.gh-issue-158314.SZiMPV.rst diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 3879c49c714dd9..ab5b306ff6a7e4 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -53,7 +53,7 @@ from test.support import ( captured_stderr, cpython_only, requires_docstrings, import_helper, run_code, subTests, EqualToForwardRef, - exceeds_recursion_limit, run_with_limited_c_stack, + run_with_limited_c_stack, skip_wasi_stack_overflow, skip_emscripten_stack_overflow, ) from test.typinganndata import ( @@ -5097,12 +5097,14 @@ class MM2(collections.abc.MutableMapping, MutableMapping[str, str]): self.assertEqual(MM2.__bases__, (collections.abc.MutableMapping, Generic)) @cpython_only - @run_with_limited_c_stack() + @run_with_limited_c_stack(500_000) @skip_wasi_stack_overflow() @skip_emscripten_stack_overflow() def test_parameters_deep_recursion(self): + # _Py_make_parameters() has small C frames (48 bytes per level + # on 32-bit ARM), so 150_000 levels can fit in the limited C stack. x = [0] - for _ in range(exceeds_recursion_limit()): + for _ in range(500_000): x = [x] with self.assertRaisesRegex(RecursionError, "in __parameter__ calculation"): list[x].__parameters__ diff --git a/Misc/NEWS.d/next/Tests/2026-11-12-05-39-56.gh-issue-158314.SZiMPV.rst b/Misc/NEWS.d/next/Tests/2026-11-12-05-39-56.gh-issue-158314.SZiMPV.rst new file mode 100644 index 00000000000000..cc547ae93d5773 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-12-05-39-56.gh-issue-158314.SZiMPV.rst @@ -0,0 +1,3 @@ +Fix ``test_typing.GenericTests.test_parameters_deep_recursion`` on 32-bit +ARM debug builds, where 150,000 nested lists did not exhaust the limited C +stack.