Skip to content

Commit 6950baf

Browse files
authored
more algorithm-independent GC infra (#7194)
* mark poluting tests * GC-infra independent to EBR * trashcan * add overflow guard to inc(), #[must_use] on dec()/safe_inc(), trashcan debug_assert, weakref generic re-check
1 parent f9ca638 commit 6950baf

27 files changed

Lines changed: 779 additions & 150 deletions

.cspell.dict/cpython.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ uncollectable
195195
Unhandle
196196
unparse
197197
unparser
198+
untracking
198199
VARKEYWORDS
199200
varkwarg
200201
venvlauncher
@@ -209,5 +210,6 @@ webpki
209210
winconsoleio
210211
withitem
211212
withs
213+
worklist
212214
xstat
213215
XXPRIME

.cspell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"emscripten",
6767
"excs",
6868
"finalizer",
69+
"finalizers",
6970
"GetSet",
7071
"groupref",
7172
"internable",
@@ -122,12 +123,14 @@
122123
"tracebacks",
123124
"typealiases",
124125
"typevartuples",
126+
"uncollectable",
125127
"unhashable",
126128
"uninit",
127129
"unraisable",
128130
"unresizable",
129131
"varint",
130132
"wasi",
133+
"weaked",
131134
"zelf",
132135
// unix
133136
"posixshmem",

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ winresource = "0.1"
3434
rustpython-compiler = { workspace = true }
3535
rustpython-pylib = { workspace = true, optional = true }
3636
rustpython-stdlib = { workspace = true, optional = true, features = ["compiler"] }
37-
rustpython-vm = { workspace = true, features = ["compiler"] }
37+
rustpython-vm = { workspace = true, features = ["compiler", "gc"] }
3838
ruff_python_parser = { workspace = true }
3939

4040
cfg-if = { workspace = true }

Lib/test/support/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,6 @@ def disable_gc():
883883

884884
@contextlib.contextmanager
885885
def gc_threshold(*args):
886-
# TODO: RUSTPYTHON; GC is not supported yet
887-
try:
888-
yield
889-
finally:
890-
pass
891-
return
892-
893886
import gc
894887
old_threshold = gc.get_threshold()
895888
gc.set_threshold(*args)

Lib/test/test_asyncio/test_ssl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,6 @@ async def test(ctx):
16491649
# SSLProtocol should be DECREF to 0
16501650
self.assertIsNone(ctx())
16511651

1652-
@unittest.expectedFailure # TODO: RUSTPYTHON; - gc.collect() doesn't release SSLContext properly
16531652
def test_shutdown_timeout_handler_leak(self):
16541653
loop = self.loop
16551654

Lib/test/test_descr.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5117,7 +5117,6 @@ def __new__(cls):
51175117
cls.lst = [2**i for i in range(10000)]
51185118
X.descr
51195119

5120-
@unittest.expectedFailure # TODO: RUSTPYTHON
51215120
def test_remove_subclass(self):
51225121
# bpo-46417: when the last subclass of a type is deleted,
51235122
# remove_subclass() clears the internal dictionary of subclasses:

Lib/test/test_faulthandler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ def test_sigsegv(self):
199199
3,
200200
'Segmentation fault')
201201

202-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Regex didn't match: '(?m)^Fatal Python error: Segmentation fault\n\n<Cannot show all threads while the GIL is disabled>\nStack\\ \\(most\\ recent\\ call\\ first\\):\n File "<string>", line 9 in __del__\nCurrent thread\'s C stack trace \\(most recent call first\\):\n( Binary file ".+"(, at .*(\\+|-)0x[0-9a-f]+)? \\[0x[0-9a-f]+\\])|(<.+>)' not found in 'exit'
203202
@skip_segfault_on_android
204203
def test_gc(self):
205204
# bpo-44466: Detect if the GC is running

Lib/test/test_functools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,6 @@ def f():
21052105
return 1
21062106
self.assertEqual(f.cache_parameters(), {'maxsize': 1000, "typed": True})
21072107

2108-
@unittest.expectedFailure # TODO: RUSTPYTHON; GC behavior differs from CPython's refcounting
21092108
def test_lru_cache_weakrefable(self):
21102109
@self.module.lru_cache
21112110
def test_function(x):

Lib/test/test_inspect/test_inspect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,6 @@ def __getattribute__(self, attr):
27142714

27152715
self.assertFalse(test.called)
27162716

2717-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: <class 'test.test_inspect.test_inspect.TestGetattrStatic.test_cache_does_not_cause_classes_to_persist.<locals>.Foo'> is not None
27182717
def test_cache_does_not_cause_classes_to_persist(self):
27192718
# regression test for gh-118013:
27202719
# check that the internal _shadowed_dict cache does not cause

Lib/test/test_io.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3813,7 +3813,6 @@ def __del__(self):
38133813
""".format(iomod=iomod, kwargs=kwargs)
38143814
return assert_python_ok("-c", code)
38153815

3816-
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
38173816
def test_create_at_shutdown_without_encoding(self):
38183817
rc, out, err = self._check_create_at_shutdown()
38193818
if err:
@@ -3823,7 +3822,6 @@ def test_create_at_shutdown_without_encoding(self):
38233822
else:
38243823
self.assertEqual("ok", out.decode().strip())
38253824

3826-
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
38273825
def test_create_at_shutdown_with_encoding(self):
38283826
rc, out, err = self._check_create_at_shutdown(encoding='utf-8',
38293827
errors='strict')
@@ -4812,13 +4810,11 @@ def run():
48124810
else:
48134811
self.assertFalse(err.strip('.!'))
48144812

4815-
@unittest.expectedFailure # TODO: RUSTPYTHON; without GC+GIL, finalize_modules clears __main__ globals while daemon threads are still running
48164813
@threading_helper.requires_working_threading()
48174814
@support.requires_resource('walltime')
48184815
def test_daemon_threads_shutdown_stdout_deadlock(self):
48194816
self.check_daemon_threads_shutdown_deadlock('stdout')
48204817

4821-
@unittest.expectedFailure # TODO: RUSTPYTHON; without GC+GIL, finalize_modules clears __main__ globals while daemon threads are still running
48224818
@threading_helper.requires_working_threading()
48234819
@support.requires_resource('walltime')
48244820
def test_daemon_threads_shutdown_stderr_deadlock(self):

0 commit comments

Comments
 (0)