File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -10389,9 +10389,20 @@ supercheck(PyTypeObject *type, PyObject *obj)
10389
10389
Py_XDECREF (class_attr );
10390
10390
}
10391
10391
10392
- PyErr_SetString (PyExc_TypeError ,
10393
- "super(type, obj): "
10394
- "obj must be an instance or subtype of type" );
10392
+ const char * type_or_instance , * obj_str ;
10393
+
10394
+ if (PyType_Check (obj )) {
10395
+ type_or_instance = "type" ;
10396
+ obj_str = ((PyTypeObject * )obj )-> tp_name ;
10397
+ } else {
10398
+ type_or_instance = "instance of" ;
10399
+ obj_str = Py_TYPE (obj )-> tp_name ;
10400
+ }
10401
+
10402
+ PyErr_Format (PyExc_TypeError ,
10403
+ "super(type, obj): obj (%s %.200s) is not an instance or subtype of type (%.200s)." ,
10404
+ type_or_instance , obj_str , type -> tp_name );
10405
+
10395
10406
return NULL ;
10396
10407
}
10397
10408
You can’t perform that action at this time.
0 commit comments