Tim Peters <t...@python.org> added the comment:

tp_clear implementations are necessary to reclaim trash cycles.  They're always 
best practice for objects that may be in trash cycles.   tuples are just "cute 
rebels" that way ;-)

Best guess is that the (some) extension isn't playing by the rules.  A weakref 
callback shouldn't be called at all unless the weakref is reachable - but in 
that case the callback function is necessarily reachable too (revealed by a 
weakrefobject's tp_traverse), so delete_garbage() should never have called 
clear() on the callback function to begin with.

Note:  I don't believe the weakref design gave any thought to cyclic gc.  The 
PEP didn't even mention it.  I got dragged into it when Zope started 
segfaulting.  They don't play well together voluntarily, but they've been 
forced to coexist, and Zope long ago provoked every fundamental problem I'm 
aware of.

That "the rules" are subtle doesn't excuse not following them ;-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38006>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to