[Python-Dev] Dealing with a desired change to warnings.showwarning()

Brett Cannon brett at python.org
Sun Apr 27 22:40:52 CEST 2008


As part of my rewrite of warnings into C, I added a new, optional
argument to showwarning(): line, which defaults to None.

As http://bugs.python.org/issue2705 points out, though, since the
function has been documented as being allowed to be overridden, this
potentially breaks existing showwarning() implementations. That means
something needs to change.

One option is to introduce a new function. But what to name it?
show_warning()? That small of a name change seems like asking for
trouble, but showwarning_ex() just seems wrong to use in Python code.

Another is that where showwarning() is called within the code, if a
TypeError is raised or introspection proves the call can't work, then
to try again without the 'line' argument, and raise a deprecation
warning.

Or try to re-architect _warnings.c to not use the 'line' argument
(although it is handy for testing purposes).

Anyway, people have any suggestions?

-Brett


More information about the Python-Dev mailing list