Martin Panter added the comment:
Actually, I found a regression. Looks like you also need to cancel any
showwarning() function set by the user:
>>> import warnings
>>> warnings.showwarning = print
>>> with warnings.catch_warnings(record=True) as recording:
... warnings.warn("hi") # Unpatched did not call print()
...
hi <class 'UserWarning'> __main__ 2 None None
>>> recording # Unpatched returned the warning here
[]
Also, should the documentation of catch_warnings() be amended to say that there
is no longer a custom showwarning() function? The recording mechanism is now an
internal detail, and not accessible by calling showwarning().
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28835>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com