diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-14 21:18:31 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-14 21:18:31 +0300 |
commit | c1d9bb342c40ba1e7b0cf69214726d269f1d74db (patch) | |
tree | f971494fc467034d9f7ac082fc9930d76dde5764 /Python/_warnings.c | |
parent | 8664b17c9457da72299bf05ca734b02c6cea00f1 (diff) | |
parent | b0e630183e0663e0651c5d8fe54a15fb46699d0c (diff) | |
download | cpython-c1d9bb342c40ba1e7b0cf69214726d269f1d74db.tar.gz |
Issue #22384: An exception in Tkinter callback no longer crashes the program
when it is run with pythonw.exe.
Documented that Tk.report_callback_exception() is purposed to be overriden in
applications.
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r-- | Python/_warnings.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 6013d7d7d4..363c1f29bb 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -619,16 +619,17 @@ get_category(PyObject *message, PyObject *category) if (rc == 1) category = (PyObject*)message->ob_type; - else if (category == NULL) + else if (category == NULL || category == Py_None) category = PyExc_UserWarning; /* Validate category. */ rc = PyObject_IsSubclass(category, PyExc_Warning); - if (rc == -1) - return NULL; - if (rc == 0) { - PyErr_SetString(PyExc_ValueError, - "category is not a subclass of Warning"); + /* category is not a subclass of PyExc_Warning or + PyObject_IsSubclass raised an error */ + if (rc == -1 || rc == 0) { + PyErr_Format(PyExc_TypeError, + "category must be a Warning subclass, not '%s'", + Py_TYPE(category)->tp_name); return NULL; } |