summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-03-12 12:00:49 (GMT)
committerGitHub <noreply@github.com>2024-03-12 12:00:49 (GMT)
commit02918aa96117781261cb1a564e37a861b01eb883 (patch)
tree77dc25055185df60fb01950c7432466cda2ce9f8 /Lib
parenteb947cdc1374842a32fa82249ba3c688abf252dc (diff)
downloadcpython-02918aa96117781261cb1a564e37a861b01eb883.zip
cpython-02918aa96117781261cb1a564e37a861b01eb883.tar.gz
cpython-02918aa96117781261cb1a564e37a861b01eb883.tar.bz2
gh-116604: Correctly honor the gc status when calling _Py_RunGC (#116628)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_gc.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index dd09643..2aea025 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1397,6 +1397,31 @@ class GCTogglingTests(unittest.TestCase):
# empty __dict__.
self.assertEqual(x, None)
+ def test_indirect_calls_with_gc_disabled(self):
+ junk = []
+ i = 0
+ detector = GC_Detector()
+ while not detector.gc_happened:
+ i += 1
+ if i > 10000:
+ self.fail("gc didn't happen after 10000 iterations")
+ junk.append([]) # this will eventually trigger gc
+
+ try:
+ gc.disable()
+ junk = []
+ i = 0
+ detector = GC_Detector()
+ while not detector.gc_happened:
+ i += 1
+ if i > 10000:
+ break
+ junk.append([]) # this may eventually trigger gc (if it is enabled)
+
+ self.assertEqual(i, 10001)
+ finally:
+ gc.enable()
+
class PythonFinalizationTests(unittest.TestCase):
def test_ast_fini(self):