summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2011-07-18 02:17:55 (GMT)
committerBrett Cannon <brett@python.org>2011-07-18 02:17:55 (GMT)
commit52a7d982736fd4111b7937c4e575adb1a39f8afa (patch)
tree81a73e3f745620057a1f0486b9fa08fddac0dd47 /Python
parentb05be7d936051a04a529fb7ad63731aeabe0fb9b (diff)
downloadcpython-52a7d982736fd4111b7937c4e575adb1a39f8afa.zip
cpython-52a7d982736fd4111b7937c4e575adb1a39f8afa.tar.gz
cpython-52a7d982736fd4111b7937c4e575adb1a39f8afa.tar.bz2
Make warnings accept a callable for showwarnings instead of
restricting itself to just functions and methods (which allows built-in functions to be used, etc.). Closes issue #10271. Thanks to lekma for the bug report.
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 615a2d3..f8a7175 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -409,10 +409,10 @@ warn_explicit(PyObject *category, PyObject *message,
else {
PyObject *res;
- if (!PyMethod_Check(show_fxn) && !PyFunction_Check(show_fxn)) {
+ if (!PyCallable_Check(show_fxn)) {
PyErr_SetString(PyExc_TypeError,
"warnings.showwarning() must be set to a "
- "function or method");
+ "callable");
Py_DECREF(show_fxn);
goto cleanup;
}