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

Ok, I found the problem. The problem is that the reproduced does not correctly 
work the reference count of base_class because when construction get tuple of 
bases:

PyObject *bases = PyTuple_New(1);
result = PyTuple_SetItem(bases, 0, base_class);
if (result) return -1;

PyObject *subclass = PyType_FromModuleAndSpec(m, &subclass_spec, bases);

"PyTuple_SetItem" steals a reference to base_class but "PyModule_AddObject" 
also does the same, and the refcount is incorrect.

If you add a Py_INCREF before, the crash disappears.

----------

_______________________________________
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