https://github.com/python/cpython/commit/5d0abb69715b9638f26c896444643055ec2ef038
commit: 5d0abb69715b9638f26c896444643055ec2ef038
branch: main
author: Mikhail Efimov <[email protected]>
committer: markshannon <[email protected]>
date: 2025-10-20T11:45:07+01:00
summary:

gh-139951: Test on GC collection disabled if threshold is zero (GH-140304)

files:
M Lib/test/test_gc.py

diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 4328909053465e..70d9d009fa8bfd 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)
+    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):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to