Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 960d948

Browse files
committed
improved error message-- names the type of the unexpected object
1 parent 69f086c commit 960d948

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Python/ceval.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,8 +2493,9 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
24932493
else {
24942494
/* Not something you can raise. You get an exception
24952495
anyway, just not what you specified :-) */
2496-
PyErr_SetString(PyExc_TypeError,
2497-
"exceptions must be strings, classes, or instances");
2496+
PyErr_Format(PyExc_TypeError,
2497+
"exceptions must be strings, classes, or "
2498+
"instances, not %s", type->ob_type->tp_name);
24982499
goto raise_error;
24992500
}
25002501
PyErr_Restore(type, value, tb);

0 commit comments

Comments
 (0)