[issue21724] resetwarnings doesn't reset warnings registry

Julian Berman report at bugs.python.org
Sun May 24 12:40:34 EDT 2020


Julian Berman <Julian+Python.org at GrayVines.com> added the comment:

Just ran into this myself -- not sure what the intended fix is (hopefully it's "add a function that restores the warnings configuration to its defaults?" Changing resetwarnings seems likely to be not doable I assume.)

But in the meanwhile, is a doc patch acceptable? The current documentation for resetwarnings is really deceptive, and makes it look like it does what @pitrou (and I) thought it did:

> Reset the warnings filter. This discards the effect of all previous calls to filterwarnings(), including that of the -W command line options and calls to simplefilter().

Compare to the docstring of the function (and to what it actually does):

> """Clear the list of warning filters, so that no filters are active."""

But there are still too many implementation details of the warnings module leaking through here -- for end users it's just "restore the warnings configuration to its defaults" (what it looks like resetwarnings should do) or "unfilter all warnings, even beyond the filters configured by default" (what it actually does).

Is at least making the docs reflect the latter a reasonable patch to submit, to start, while what to do about the former is thought about?

----------
assignee:  -> docs at python
components: +Documentation
nosy: +Julian, docs at python
versions: +Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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


More information about the Python-bugs-list mailing list