Robert Collins added the comment: @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. ---------- nosy: +rbcollins stage: commit review -> patch review _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18383> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com