diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-22 09:09:24 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-22 09:09:24 +0100 |
commit | 3fd279ebe09bbd98f93b1a74e44bf69b05f28b14 (patch) | |
tree | a29b724be9b4d73eaf040c1da3f06eb30440304c /Python/_warnings.c | |
parent | f21948c9b62b6c4e31a5d10f4c4eddd8cb3e2331 (diff) | |
parent | 7d98c6e7cca7c964ce01afdf88125b147b57943f (diff) | |
download | cpython-3fd279ebe09bbd98f93b1a74e44bf69b05f28b14.tar.gz |
Merge 3.4
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 bef56479b3..a1f4368ebe 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -637,16 +637,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; } |