diff options
| author | Brett Cannon <brett@python.org> | 2011-07-17 19:17:55 -0700 |
|---|---|---|
| committer | Brett Cannon <brett@python.org> | 2011-07-17 19:17:55 -0700 |
| commit | 471239a1458855de653c1986ab17453b509944c9 (patch) | |
| tree | d9e6a413ee8f634e0a5347afb1b9e4c8880d2aa9 /Python/_warnings.c | |
| parent | 21e05e97224070ba6b8c2ffbd46130aa7d293307 (diff) | |
| download | cpython-471239a1458855de653c1986ab17453b509944c9.tar.gz | |
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/_warnings.c')
| -rw-r--r-- | Python/_warnings.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 615a2d3217..f8a7175f92 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; } |
