[issue34948] Document __warningregister__

Serhiy Storchaka report at bugs.python.org
Wed Oct 10 09:39:39 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

And this case looks like playing with implementation details.

The official way to make the specified warning emitted more than once is to use warnings.filterwarnings():

>>> import warnings
>>> warnings.filterwarnings('always', "NOBODY expects the Spanish Inquisition!", UserWarning)
>>> warnings.warn("NOBODY expects the Spanish Inquisition!")
<stdin>:1: UserWarning: NOBODY expects the Spanish Inquisition!
>>> warnings.warn("NOBODY expects the Spanish Inquisition!")
<stdin>:1: UserWarning: NOBODY expects the Spanish Inquisition!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34948>
_______________________________________


More information about the Python-bugs-list mailing list