Issue #12149: Update the method cache after a type's dictionnary gets

cleared by the garbage collector.  This fixes a segfault when an instance
and its type get caught in a reference cycle, and the instance's
deallocator calls one of the methods on the type (e.g. when subclassing
IOBase).

Diagnosis and patch by Davide Rizzo.
This commit is contained in:
Antoine Pitrou 2011-07-12 21:58:39 +02:00
commit 093c8e4bf0
4 changed files with 27 additions and 1 deletions

View file

@ -967,6 +967,8 @@ subtype_dealloc(PyObject *self)
assert(basedealloc);
basedealloc(self);
PyType_Modified(type);
/* Can't reference self beyond this point */
Py_DECREF(type);