summaryrefslogtreecommitdiff
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2015-01-23 21:19:53 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2015-01-23 21:19:53 +0000
commit25e326da3d6019e27a1313adcfd04f40fe8e7f77 (patch)
tree101f889280999cff5b2cba58721a93d204e6e689 /Python/_warnings.c
parent602523212f6e8c403c43001bbee92623602ecce1 (diff)
parent8dd2d03028fc496557f4ab52e6fa36c119773236 (diff)
downloadcpython-25e326da3d6019e27a1313adcfd04f40fe8e7f77.tar.gz
Closes #23305: Merged documentation fix from 3.4.
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c13
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;
}