Mercurial > cpython-lru_cache-weakref
diff Python/_warnings.c @ 71400:aaced3dcb858
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.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Sun, 17 Jul 2011 19:17:55 -0700 |
| parents | 7eb85a23cf3d |
| children | 8beaa9a37387 |
line wrap: on
line diff
--- a/Python/_warnings.c Sun Jul 17 16:22:05 2011 -0700 +++ b/Python/_warnings.c Sun Jul 17 19:17:55 2011 -0700 @@ -409,10 +409,10 @@ 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; }
