summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-03-12 23:38:20 (GMT)
committerGitHub <noreply@github.com>2024-03-12 23:38:20 (GMT)
commitdcfb21d8b4c930c4295cd9a75814316e5b103683 (patch)
tree4a13d74cfee81fd202df627021f77939d46f8935 /Lib
parentf9d1ec8e803012a521f0673da8c5cba1e9862bf5 (diff)
downloadcpython-dcfb21d8b4c930c4295cd9a75814316e5b103683.zip
cpython-dcfb21d8b4c930c4295cd9a75814316e5b103683.tar.gz
cpython-dcfb21d8b4c930c4295cd9a75814316e5b103683.tar.bz2
[3.12] gh-116604: Correctly honor the gc status when calling _Py_RunGC (GH-116628) (#116653)
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 db7cb9ac..81bb5bb 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1387,6 +1387,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):