]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport of 2.242:
authorAnthony Baxter <anthonybaxter@gmail.com>
Wed, 21 Nov 2001 04:49:19 +0000 (04:49 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Wed, 21 Nov 2001 04:49:19 +0000 (04:49 +0000)
improved error message-- names the type of the unexpected object

Python/ceval.c

index ccab1585679b13a39a260e3382f71acc3ff33bbf..72e4b6b7d697953162cecbc1a3e0979e77882525 100644 (file)
@@ -2470,8 +2470,9 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
        else {
                /* Not something you can raise.  You get an exception
                   anyway, just not what you specified :-) */
-               PyErr_SetString(PyExc_TypeError,
-                   "exceptions must be strings, classes, or instances");
+               PyErr_Format(PyExc_TypeError,
+                            "exceptions must be strings, classes, or "
+                            "instances, not %s", type->ob_type->tp_name);
                goto raise_error;
        }
        PyErr_Restore(type, value, tb);