[New-bugs-announce] [issue4180] warnings.simplefilter("always") does not make warnings always show up

Jean-Paul Calderone report at bugs.python.org
Wed Oct 22 23:49:32 CEST 2008


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

If a warning is emitted then a filter with the "always" rule is added
then the is emitted again, it will not be shown the second time:

  exarkun at charm:~$ python
  Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
  [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import warnings
  >>> def f():
  ...     warnings.warn("foo")
  ... 
  >>> f()
  /home/exarkun/.pythonstartup.py:2: UserWarning: foo
  >>> warnings.simplefilter("always")
  >>> f()
  >>> 

The "always" filter is documented as "always print matching warnings"
which is contrary to this behavior.  Also, the string "always" strongly
implies that it will be shown the second time.

----------
messages: 75113
nosy: exarkun
severity: normal
status: open
title: warnings.simplefilter("always") does not make warnings always show up
versions: Python 2.4, Python 2.5, Python 2.6

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


More information about the New-bugs-announce mailing list