Skip to content

Commit

Permalink
pythongh-113212: Improve super() error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframAlph committed Dec 20, 2023
1 parent 4afa7be commit 09d3ddb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -10389,9 +10389,13 @@ supercheck(PyTypeObject *type, PyObject *obj)
Py_XDECREF(class_attr);
}

PyErr_SetString(PyExc_TypeError,
PyErr_Format(PyExc_TypeError,
"super(type, obj): "
"obj must be an instance or subtype of type");
"obj must be an instance or subtype of type. "
"Got obj: '%.200s', type: '%.200s'.",
PyType_Check(obj) ? ((PyTypeObject*)obj)->tp_name : Py_TYPE(obj)->tp_name,
type->tp_name);

return NULL;
}

Expand Down

0 comments on commit 09d3ddb

Please sign in to comment.