summaryrefslogtreecommitdiff
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2015-01-22 22:56:06 -0800
committerGregory P. Smith <greg@krypto.org>2015-01-22 22:56:06 -0800
commit8d0474182b3c0dba017357ed7e3a7d6b5a0e05cb (patch)
tree5635e9e954272393a993fdaa3cf563e91f86f383 /Python/_warnings.c
parent52d4e1bd942e0dd6209c9e60b3f3cc98eea14b90 (diff)
parent07a465b24e1fc5e4804e536312c917017d0b663e (diff)
downloadcpython-8d0474182b3c0dba017357ed7e3a7d6b5a0e05cb.tar.gz
revert 7b833bd1f509. I misread the side effect that the code was triggering.
*any* kwarg supplied to _assert_python causes it to not append -E to the command line flags so without='-E' does effectively work.
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;
}