Bugs item #1548371, was opened at 2006-08-29 02:27 Message generated for change (Comment added) made by rupole You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1548371&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Roger Upole (rupole) Assigned to: Nobody/Anonymous (nobody) Summary: filterwarnings('error') has no effect Initial Comment: Once a warning has already been issued, warnings.filterwarnings('error',...) will not cause an error to be raised. When the attached script is run, the warning is printed the first time thru the loop, but no error is raised the 2nd time thru. Likewise, warnings.filterwarnings('always',...) will not cause the warning to be printed again. ---------------------------------------------------------------------- >Comment By: Roger Upole (rupole) Date: 2006-09-01 12:19 Message: Logged In: YES user_id=771074 Without the cache, the only filters you could possibly implement would be 'error' and 'ignore'. ---------------------------------------------------------------------- Comment By: Marien Zwart (marienz) Date: 2006-09-01 05:44 Message: Logged In: YES user_id=857292 The whole point of that cache is to not go through the list of filters if the warning is in the cache. Why would you keep the cache around if you search through the filters in every case anyway? ---------------------------------------------------------------------- Comment By: Roger Upole (rupole) Date: 2006-08-31 23:38 Message: Logged In: YES user_id=771074 It might be simpler to check if the warning is in the line cache after the disposition is determined from the filters. In the case of 'always' and 'error', there's no need to check the cache at all. ---------------------------------------------------------------------- Comment By: Marien Zwart (marienz) Date: 2006-08-31 15:34 Message: Logged In: YES user_id=857292 This is caused by the warnings module caching when a combination of message, Warning subclass and linenumber gets ignored and bypassing the search through the warning filters when that same combination occurs again. I think it is possible to avoid this problem while keeping the cache by keeping track of the "version" of the filters list (a simple integer that is incremented every time the filters list is modified through the functions in the warnings module) and including this in the key tuple warn_explicit uses to remember previous ignores. Old stuff would remain in the cache but that should not be a big problem (changes to the filters list should not be that common). Does this sound reasonable? If it does I'll see if I can produce a patch. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1548371&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com