[Python-Dev] DeprecationWarnings in the regression tests (original) (raw)

Tim Peters tim.one@comcast.net
Mon, 15 Apr 2002 20:13:42 -0400


Damn. warnings.resetwarnings() doesn't really

"""Reset the list of warnings filters to its default state."""

if by "its default state" one means (as I do ) its initial state upon importing the warnings module.

I had the clever idea of calling warnings.resetwarnings() in regrtest.py after running each test, at least so that the damage done by a sloppy overly-general warning suppression added by one test couldn't hurt error reporting in other tests.

But an unwanted side effect is that I'm getting brand new "surprise" warnings now, because warnings.py does

filterwarnings("ignore", category=OverflowWarning, append=1)

as part of its initialization, but resetwarnings nukes that.

What should resetwarnings really do? Offhand it looks most reasonable to me to move the module initialization code

_processoptions(sys.warnoptions)
filterwarnings("ignore", category=OverflowWarning, append=1)

into the body of resetwarnings(), then call the latter from the initialization block.

Objections?