> We can have finalizer code running during delete_garbage(). That
> code should not have access to non-valid objects. Weakrefs seem be
> a way to violate that. handle_weakrefs() take care of some of them
> but it seems there are other issues.
I see that handle_weakrefs() calls _PyWeakref_ClearRef() and that
will clear the weakref even if it doesn't have callback. So, I
think that takes care for the hole I was worried about. I.e. a
__del__ method could have a weakref to an non-valid object.
However, because handle_weakrefs() will find that weakref, it will
have been cleared when the __del__ method executes.