diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-13 09:36:06 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-13 09:36:06 +0300 |
commit | 5be034cf6165724587beb18dca9e5b7682442a74 (patch) | |
tree | 6b6cef1d5851e7f5770aa78f9290dba4f546bb01 /Python/_warnings.c | |
parent | b1ec624fe7b26b6a23658840b50b15b372de670e (diff) | |
parent | 8128e231900edc5b5f035f83186cb7507271ab84 (diff) | |
download | cpython-5be034cf6165724587beb18dca9e5b7682442a74.tar.gz |
Issue #20729: Restored the use of lazy iterkeys()/itervalues()/iteritems()
in the mailbox module. This is partial rollback of changeset f340cb045bf9.
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; } |