Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

> Now we changed rules. A strong reference is created implicitly. Who is 
> responsible to manage a strong reference? Whose who created it, ant it is the 
> interpreter, not the user.

Even if we decide that the patch that introduced the new rules should not be 
reverted, then what we should do is wrap the tp_traverse of the user in 
something that also calls Py_VISIT(Py_TYPE(self)) so basically the tp_traverse 
of the type created by PyType_FromSpec will do

static int
PyType_FromSpec_tp_traverse(_abc_data *self, visitproc visit, void *arg)
{
    Py_VISIT(Py_TYPE(self))
    return self->user_provided_tp_traverse(self, visit, arg);
}

That way, we can still reason about what the tp_traverse should do, we don't 
break more rules and we don't need to make maintaining the GC even more 
difficult.

----------

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

Reply via email to