[New-bugs-announce] [issue10271] warnings.showwarning should allow any callable object

lekma report at bugs.python.org
Sun Oct 31 19:53:35 CET 2010


New submission from lekma <lekmalek at gmail.com>:

Overriding warnings.showwarning() with a c/python module function (from a c/python module) doesn't work because warn_explicit() only allow PyFunction or PyMethod objects to be called (unfortunately c/python module functions are of type PyCFunction).

Suggested changes in _warnings.c (from py3k) - not tested at all:

from:
412            if (!PyMethod_Check(show_fxn) && !PyFunction_Check(show_fxn)) {
413                PyErr_SetString(PyExc_TypeError,
414                                "warnings.showwarning() must be set to a "
415                                "function or method");

to:
412            if (!PyCallable_Check(show_fxn)) {
413                PyErr_SetString(PyExc_TypeError,
414                                "warnings.showwarning() must be set to a "
415                                "callable");

----------
components: Library (Lib)
messages: 120080
nosy: lekma
priority: normal
severity: normal
status: open
title: warnings.showwarning should allow any callable object
type: feature request
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10271>
_______________________________________


More information about the New-bugs-announce mailing list