Neil Schemenauer <[email protected]> added the comment:
> It's fundamentally insane to expect any gc to work perfectly when it may be
> blind to what the object graph _is_.
I'm often amazed it works at all, let alone perfectly. ;-P
This did trigger me to think of another possible problem. I setup my unit test
as you suggested:
# Z <- Y <- A--+--> WZ -> C
# ^ |
# +--+
# where:
# WZ is a weakref to Z with callback C
# Y doesn't implement tp_traverse
# A contains a reference to itself, Y and WZ
But what happens if the GC doesn't see that WZ is trash? Then it will not be
cleared. Hang it off Y so the GC can't find it. We can set things up so that
Z is freed before WZ (e.g. WZ in a second and newer cycle). Then, the callback
might still run.
On further thought, this seems safe (but maybe broken) because of the
handle_weakrefs() logic. The GC will think WZ is going to outlive Z so it will
call it before doing any tp_clear calls.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38006>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com