which gets `tp_dealloc`-ed. # This drops the last reference to `latefin`. latefin = LateFin() def func(): pass cyc = tuple.__new__(Cyclic, (func, latefin)) # 1. Create a reference cycle of `cyc` and `func`. func.__module__ = cyc # 2. Make the cycle unreachable, but keep the global reference # to `latefin` so that it isn't detected as garbage. This # way its finalizer will not be called immediately. del func, cyc # 3. Invoke garbage collection, # which will find `cyc` and `func` as garbage. gc.collect() # 9. Previously, this would crash because `func_qualname` # had been NULL-ed out by func_clear(). print(f"{func=}") ú