From 5b1f721722d8a0fa638aeac6dc096cfb5030d0ae Mon Sep 17 00:00:00 2001 From: Mikhail Efimov Date: Sat, 18 Oct 2025 20:23:19 +0300 Subject: [PATCH 1/2] Test added --- Lib/test/test_gc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 4328909053465e..02a56d26560d41 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1559,6 +1559,20 @@ def test_indirect_calls_with_gc_disabled(self): finally: gc.enable() + # Ensure that setting *threshold0* to zero disables collection. + @gc_threshold(0, 0, 0) + def test_threshold_zero(self): + junk = [] + i = 0 + detector = GC_Detector() + while not detector.gc_happened: + i += 1 + if i > 50000: + break + junk.append([]) # this may eventually trigger gc (if it is enabled) + + self.assertEqual(i, 50001) + class PythonFinalizationTests(unittest.TestCase): def test_ast_fini(self): From e375d2fb9f20fab199ec8d59c669da81b8552c55 Mon Sep 17 00:00:00 2001 From: Mikhail Efimov Date: Sat, 18 Oct 2025 20:37:42 +0300 Subject: [PATCH 2/2] Review addressed --- Lib/test/test_gc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 02a56d26560d41..70d9d009fa8bfd 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1560,7 +1560,7 @@ def test_indirect_calls_with_gc_disabled(self): gc.enable() # Ensure that setting *threshold0* to zero disables collection. - @gc_threshold(0, 0, 0) + @gc_threshold(0) def test_threshold_zero(self): junk = [] i = 0