File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -10389,9 +10389,22 @@ 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
+ }
10398
+ else {
10399
+ type_or_instance = "instance of" ;
10400
+ obj_str = Py_TYPE (obj )-> tp_name ;
10401
+ }
10402
+
10403
+ PyErr_Format (PyExc_TypeError ,
10404
+ "super(type, obj): obj (%s %.200s) is not "
10405
+ "an instance or subtype of type (%.200s)." ,
10406
+ type_or_instance , obj_str , type -> tp_name );
10407
+
10395
10408
return NULL ;
10396
10409
}
10397
10410
You can’t perform that action at this time.
0 commit comments