Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09d3ddb

Browse filesBrowse files
committed
gh-113212: Improve super() error message.
1 parent 4afa7be commit 09d3ddb
Copy full SHA for 09d3ddb

File tree

1 file changed

+6
-2
lines changed
Filter options

1 file changed

+6
-2
lines changed

‎Objects/typeobject.c

Copy file name to clipboardExpand all lines: Objects/typeobject.c
+6-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.