summaryrefslogtreecommitdiff
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2015-01-23 19:36:54 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2015-01-23 19:36:54 +0000
commit8fa7954e4ef26dcf377019236cc2171fb8be8355 (patch)
treea1e6fd2f3384fb9656a70174a65ea0a04ffd4861 /Python/_warnings.c
parenta2f7d2bf741a71f23cbf154cc292e610086f431f (diff)
parentc8962fe46dc4b0bfa761087a8e095e0fb001fb34 (diff)
downloadcpython-8fa7954e4ef26dcf377019236cc2171fb8be8355.tar.gz
Closes #23202: pyvenv documentation updated to match its behavior.
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;
}