[New-bugs-announce] [issue2705] incompatible change to warnings.showwarning

Jean-Paul Calderone report at bugs.python.org
Sun Apr 27 21:08:54 CEST 2008


New submission from Jean-Paul Calderone <exarkun at divmod.com>:

In Python 2.5 and earlier, the `showwarning´ function in the `warnings´
module has this signature:

  def showwarning(message, category, filename, lineno, file=None):

In trunk (and presumably what will become Python 2.6), this has become:

  def showwarning(message, category, filename, lineno, file=None,
line=None):

`showwarning´ is documented as a hook which libraries or applications
may override in order to control how warnings are reported.  The
addition of a new parameter to the function and the change to related
code to call it with an argument for that new parameter means that
libraries and applications which replaced it will not work without
modification on Python 2.6.  Instead, a `TypeError´ will be raised when
a warning is emitted.

I suggest restoring the previous signature for `showwarning´ and adding
a new (perhaps preferred) API for showing a warning with the extra
information available.  It may also make sense to emit a deprecation
warning when an overridden old-style `showwarning´ is found.

----------
components: Library (Lib)
messages: 65894
nosy: exarkun
severity: normal
status: open
title: incompatible change to warnings.showwarning
type: behavior
versions: Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2705>
__________________________________


More information about the New-bugs-announce mailing list