Closed graingert closed 1 month ago
I can work around this by passing ExceptionGroup a copy() of exceptions, and calling exceptions.clear()
a nice simple test that shows the problem here:
async def test_ki_protection_check_does_not_freeze_locals() -> None:
class A:
pass
a = A()
wr_a = weakref.ref(a)
assert not _core.currently_ki_protected()
del a
assert wr_a() is None
consider:
this prints:
so there's a reference cycle from the
exc.__traceback__.tb_frame.f_locals["exceptions"][0] is exc
, which gets cleared when you re-materialize f_localsthis is caused by this materialization of the frame f_locals https://github.com/python-trio/trio/blob/2a66a0d149ec0796a542fcf0be726e7b81aba301/src/trio/_core/_run.py#L1874
See also https://github.com/agronholm/anyio/pull/809