diff options
author | Sam Gross <colesbury@gmail.com> | 2024-01-25 18:27:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 18:27:36 (GMT) |
commit | b52fc70d1ab3be7866ab71065bae61a03a28bfae (patch) | |
tree | f364d714c70229ad70b6138aac6181d1ee375363 /Lib/test/test_gc.py | |
parent | 4850410b60183dac021ded219a49be140fe5fefe (diff) | |
download | cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.zip cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.tar.gz cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.tar.bz2 |
gh-112529: Implement GC for free-threaded builds (#114262)
* gh-112529: Implement GC for free-threaded builds
This implements a mark and sweep GC for the free-threaded builds of
CPython. The implementation relies on mimalloc to find GC tracked
objects (i.e., "containers").
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r-- | Lib/test/test_gc.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 1d71dd9..b01f344 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1,7 +1,7 @@ import unittest import unittest.mock from test.support import (verbose, refcount_test, - cpython_only, requires_subprocess) + cpython_only, requires_subprocess, Py_GIL_DISABLED) from test.support.import_helper import import_module from test.support.os_helper import temp_dir, TESTFN, unlink from test.support.script_helper import assert_python_ok, make_script @@ -819,6 +819,15 @@ class GCTests(unittest.TestCase): l = [] l.append(l) self.assertTrue( + any(l is element for element in gc.get_objects()) + ) + + @unittest.skipIf(Py_GIL_DISABLED, 'need generational GC') + def test_get_objects_generations(self): + gc.collect() + l = [] + l.append(l) + self.assertTrue( any(l is element for element in gc.get_objects(generation=0)) ) self.assertFalse( @@ -1225,7 +1234,7 @@ class GCCallbackTests(unittest.TestCase): p.stderr.close() # Verify that stderr has a useful error message: self.assertRegex(stderr, - br'gc\.c:[0-9]+: gc_decref: Assertion "gc_get_refs\(g\) > 0" failed.') + br'gc.*\.c:[0-9]+: .*: Assertion "gc_get_refs\(.+\) .*" failed.') self.assertRegex(stderr, br'refcount is too small') # "address : 0x7fb5062efc18" |