*** typeobject.c.orig Tue Dec 31 08:33:00 2002 --- typeobject.c Tue Feb 4 11:32:12 2003 *************** *** 144,149 **** --- 144,150 ---- static PyTypeObject *best_base(PyObject *); static int mro_internal(PyTypeObject *); static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *); + static int bases_compatible_for_assignment(PyTypeObject *, PyTypeObject *); static int add_subclass(PyTypeObject*, PyTypeObject*); static void remove_subclass(PyTypeObject *, PyTypeObject *); static void update_all_slots(PyTypeObject *); *************** *** 241,247 **** return -1; } ! if (!compatible_for_assignment(type->tp_base, new_base, "__bases__")) return -1; Py_INCREF(new_base); --- 242,248 ---- return -1; } ! if (!bases_compatible_for_assignment(type->tp_base, new_base)) return -1; Py_INCREF(new_base); *************** *** 2300,2305 **** --- 2301,2333 ---- } static int + bases_compatible_for_assignment(PyTypeObject *old, PyTypeObject *new) + { + PyTypeObject *solidold, *solidnew; + + solidold = solid_base(old); + solidnew = solid_base(new); + + if (solidold == solidnew) + { + PyTypeObject *base; + destructor olddealloc, newdealloc; + + base = old; + while ((olddealloc = base->tp_dealloc) == subtype_dealloc) + base = base->tp_base; + + base = new; + while ((newdealloc = base->tp_dealloc) == subtype_dealloc) + base = base->tp_base; + + if (olddealloc == newdealloc) + return 1; + } + return compatible_for_assignment(old, new, "__bases__"); + } + + static int object_set_class(PyObject *self, PyObject *value, void *closure) { PyTypeObject *old = self->ob_type;