[issue39778] collections.OrderedDict and weakref.ref raises "refcount is too small" assertion

Raymond Hettinger report at bugs.python.org
Mon Sep 20 01:51:14 EDT 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

I'm thinking that edit to tp_dealloc was incorrect.  The PyClear call should have been replaced (not removed) with the pattern shown in the C APIs docs ( https://docs.python.org/3/extending/newtypes.html?highlight=pyobject_clearw#weak-reference-support ):

    if (self->weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) self);

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39778>
_______________________________________


More information about the Python-bugs-list mailing list