Message104610
| Author |
tseaver |
| Recipients |
benjamin.peterson, brett.cannon, exarkun, flox, mark.dickinson, pitrou, tseaver |
| Date |
2010年04月30日.02:39:12 |
| SpamBayes Score |
4.0259303e-07 |
| Marked as misclassified |
No |
| Message-id |
<1272595155.16.0.764651452625.issue4180@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|