Tres Seaver <[email protected]> added the comment:
The attached patch fixes the OP's use case on the Python side by re-ordering
the tests, such that "always" prevents the short-circuit from firing::
$ ./python
Python 2.6.5+ (release26-maint, Apr 29 2010, 21:24:12)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import warnings as o_warnings
>>> import sys
>>> sys.modules['_warnings'] = 0
>>> del sys.modules['warnings']
>>> import warnings as py_warnings
>>> def f():
... py_warnings.warn('foo')
...
>>> f()
__main__:2: UserWarning: foo
>>> f()
>>> py_warnings.simplefilter('always')
>>> f()
__main__:2: UserWarning: foo
>>> f()
__main__:2: UserWarning: foo
----------
components: +Library (Lib) -Interpreter Core
nosy: +tseaver
type: behavior ->
Added file: http://bugs.python.org/file17141/issue4180-py_warnings.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue4180>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com