(self)
| 226 | gc.garbage.remove(obj) |
| 227 | |
| 228 | def test_function(self): |
| 229 | # Tricky: f -> d -> f, code should call d.clear() after the exec to |
| 230 | # break the cycle. |
| 231 | d = {} |
| 232 | exec("def f(): pass\n", d) |
| 233 | gc.collect() |
| 234 | del d |
| 235 | # In the free-threaded build, the count returned by `gc.collect()` |
| 236 | # is 3 because it includes f's code object. |
| 237 | self.assertIn(gc.collect(), (2, 3)) |
| 238 | |
| 239 | # TODO: RUSTPYTHON - weakref clear ordering differs from 3.15+ |
| 240 | @unittest.expectedFailure |