summaryrefslogtreecommitdiffstats
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 5261ef9..ea29a38 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -10404,9 +10404,22 @@ supercheck(PyTypeObject *type, PyObject *obj)
Py_XDECREF(class_attr);
}
- PyErr_SetString(PyExc_TypeError,
- "super(type, obj): "
- "obj must be an instance or subtype of type");
+ const char *type_or_instance, *obj_str;
+
+ if (PyType_Check(obj)) {
+ type_or_instance = "type";
+ obj_str = ((PyTypeObject*)obj)->tp_name;
+ }
+ else {
+ type_or_instance = "instance of";
+ obj_str = Py_TYPE(obj)->tp_name;
+ }
+
+ PyErr_Format(PyExc_TypeError,
+ "super(type, obj): obj (%s %.200s) is not "
+ "an instance or subtype of type (%.200s).",
+ type_or_instance, obj_str, type->tp_name);
+
return NULL;
}