I don't know why staring at the email to python-checkins made me
see problems with my code that I didn't see before the checkin, but:
When a subtype .mro() fails, we need to reset the type whose __bases__
are being changed, too. Fix + test.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 949cef5..d83ff8c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -242,17 +242,12 @@
type->tp_base = new_base;
if (mro_internal(type) < 0) {
- type->tp_bases = old_bases;
- type->tp_base = old_base;
- type->tp_mro = old_mro;
-
- Py_DECREF(value);
- Py_DECREF(new_base);
-
- return -1;
+ goto bail;
}
temp = PyList_New(0);
+ if (!temp)
+ goto bail;
r = mro_subclasses(type, temp);
@@ -267,7 +262,7 @@
Py_INCREF(cls->tp_mro);
}
Py_DECREF(temp);
- return r;
+ goto bail;
}
Py_DECREF(temp);
@@ -303,6 +298,16 @@
Py_DECREF(old_mro);
return r;
+
+ bail:
+ type->tp_bases = old_bases;
+ type->tp_base = old_base;
+ type->tp_mro = old_mro;
+
+ Py_DECREF(value);
+ Py_DECREF(new_base);
+
+ return -1;
}
static PyObject *