8000 gh-113212: Improve `super()` error message. · python/cpython@3b7e6fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b7e6fd

Browse files
committed
gh-113212: Improve super() error message.
1 parent 4afa7be commit 3b7e6fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Objects/typeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10389,9 +10389,13 @@ supercheck(PyTypeObject *type, PyObject *obj)
1038910389
Py_XDECREF(class_attr);
1039010390
}
1039110391

10392-
PyErr_SetString(PyExc_TypeError,
10392+
PyErr_Format(PyExc_TypeError,
1039310393
"super(type, obj): "
10394-
"obj must be an instance or subtype of type");
10394+
"obj must be an instance or subtype of type. "
10395+
"Got obj: '%.200s', type: '%.200s'.",
10396+
PyType_Check(obj) ? ((PyTypeObject*)obj)->tp_name : Py_TYPE(obj)->tp_name,
10397+
type->tp_name);
10398+
1039510399
return NULL;
1039610400
}
1039710401

0 commit comments

Comments
 (0)
0