From 277e258bff2a8848a36d397667074a685fdfae73 Mon Sep 17 00:00:00 2001 From: Noah <57315647+zolaski333@users.noreply.github.com> Date: Wed, 14 Oct 2026 04:38:50 +0200 Subject: [PATCH] gh-159293: Restore the recursion limit after the free-threading race test (GH-159311) Adds a cleanup to ensure interpreter state is restored after testing recursion limit changes. (cherry picked from commit aeff4cb4c4b38744037f7ea88d2241c66c17a7eb) Co-authored-by: Noah <57315647+zolaski333@users.noreply.github.com> --- Lib/test/test_free_threading/test_races.py | 2 ++ .../next/Tests/2026-10-13-13-34-00.gh-issue-159293.Lr8q2N.rst | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-10-13-13-34-00.gh-issue-159293.Lr8q2N.rst diff --git a/Lib/test/test_free_threading/test_races.py b/Lib/test/test_free_threading/test_races.py index 23b48c76195408..f08de7496eb526 100644 --- a/Lib/test/test_free_threading/test_races.py +++ b/Lib/test/test_free_threading/test_races.py @@ -272,6 +272,8 @@ def mutate(): do_race(set_value, mutate) def test_racing_recursion_limit(self): + self.addCleanup(sys.setrecursionlimit, sys.getrecursionlimit()) + def something_recursive(): def count(n): if n > 0: diff --git a/Misc/NEWS.d/next/Tests/2026-10-13-13-34-00.gh-issue-159293.Lr8q2N.rst b/Misc/NEWS.d/next/Tests/2026-10-13-13-34-00.gh-issue-159293.Lr8q2N.rst new file mode 100644 index 00000000000000..2a122343a3fe2a --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-10-13-13-34-00.gh-issue-159293.Lr8q2N.rst @@ -0,0 +1,2 @@ +Restore the recursion limit after the free-threading recursion-limit race test +to avoid failures in subsequent tests run in the same process.