diff -r 98399c347108 Lib/warnings.py --- a/Lib/warnings.py Thu Apr 29 22:34:25 2010 +0200 +++ b/Lib/warnings.py Fri Apr 30 06:20:37 2010 -0400 @@ -216,9 +216,6 @@ text = message message = category(message) key = (text, category, lineno) - # Quick test for common case - if registry.get(key): - return # Search the filters for item in filters: action, msg, cat, mod, ln = item @@ -229,39 +226,40 @@ break else: action = defaultaction - # Early exit actions - if action == "ignore": - registry[key] = 1 - return # Prime the linecache for formatting, in case the # "file" is actually in a zipfile or something. linecache.getlines(filename, module_globals) + # Early exit actions + emit = key not in registry if action == "error": raise message - # Other actions - if action == "once": - registry[key] = 1 + elif action == "ignore": + return + elif action == "once": oncekey = (text, category) if onceregistry.get(oncekey): return onceregistry[oncekey] = 1 - elif action == "always": - pass + emit = True elif action == "module": - registry[key] = 1 altkey = (text, category, 0) if registry.get(altkey): return registry[altkey] = 1 - elif action == "default": - registry[key] = 1 - else: + emit = True + elif action == "always": + emit = True + elif action != "default": # Unrecognized actions are errors raise RuntimeError( "Unrecognized action (%r) in warnings.filters:\n %s" % (action, item)) + if not emit: + return + registry[key] = 1 + # Warn if showwarning() does not support the 'line' argument. # Don't use 'inspect' as it relies on an extension module, which break the # build thanks to 'warnings' being imported by setup.py.