This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rbcollins
Recipients ashkop, berker.peksag, ezio.melotti, flox, martin.panter, rbcollins, serhiy.storchaka
Date 2015-08-12.22:01:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439416910.03.0.997267711198.issue18383@psf.upfronthosting.co.za>
In-reply-to
Content
@ashkop so append=True could be clearer as 'atend=True' - both forms of call are expected to add the filter, but one adds to the front, one to the end.

Looking at warn_explicit, its takes the first matching filter, and then acts on its action.

So the following:
simplefilter("ignore")
simplefilter("error", append=True)
simplefilter("ignore", append=True)

will ignore all warnings today.

With this patch it will error on all warnings.

So at *best* I think this is a breaking API change.

Old:
>>> from warnings import simplefilter, warn
>>> simplefilter("ignore")
>>> simplefilter("error", append=True)
>>> simplefilter("ignore", append=True)
>>> warn("boo")
>>> 

With this patch:
>>> from warnings import simplefilter, warn
>>> simplefilter("ignore")
>>> simplefilter("error", append=True)
>>> simplefilter("ignore", append=True)
>>> warn("boo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UserWarning: boo
>>> 

Now, perhaps its desirable to make this change. I haven't decided yet about the tastefulness of the new API, but if we do we're going to need docstring updates, and API doc changes to match it.

Since the goal here is to fix module reloads, I think the right way to do that is to only change the module initialisation code.

e.g. add an optional 'no_duplicate' parameter to simplefilter and use that from the module initialisation. Thats backwards compatible and opt-in. If we don't think it should be public, make it a _ prefixed parameter. I think it would be fine to be public though.
History
Date User Action Args
2015-08-12 22:01:50rbcollinssetrecipients: + rbcollins, ezio.melotti, flox, berker.peksag, martin.panter, serhiy.storchaka, ashkop
2015-08-12 22:01:50rbcollinssetmessageid: <1439416910.03.0.997267711198.issue18383@psf.upfronthosting.co.za>
2015-08-12 22:01:50rbcollinslinkissue18383 messages
2015-08-12 22:01:49rbcollinscreate