← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jml/launchpad/show-warnings-once into lp:launchpad/devel

 

Jonathan Lange has proposed merging lp:~jml/launchpad/show-warnings-once into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


It turns out that we blat all over Python's normal warning filtering and show every instance of every warning. This sucks *and* blows at the same time, so I've cobbled together a crappy little hack to fix it.

It's pretty hard to verify that this hack works, so I'm running the branch through ec2 test now.

-- 
https://code.launchpad.net/~jml/launchpad/show-warnings-once/+merge/31831
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jml/launchpad/show-warnings-once into lp:launchpad/devel.
=== modified file 'lib/lp/scripts/utilities/warninghandler.py'
--- lib/lp/scripts/utilities/warninghandler.py	2010-07-27 13:56:42 +0000
+++ lib/lp/scripts/utilities/warninghandler.py	2010-08-05 10:22:53 +0000
@@ -17,6 +17,9 @@
         self.message = message
         self.info = info
 
+    def __hash__(self):
+        return hash(self.message)
+
     def __str__(self):
         info = str(self.info)
         if info:
@@ -147,7 +150,7 @@
 
 need_page_titles = []
 no_order_by = []
-other_warnings = []
+other_warnings = set()
 
 old_show_warning = warnings.showwarning
 def launchpad_showwarning(message, category, filename, lineno, file=None,
@@ -177,7 +180,7 @@
                     WarningReport(warning_message, important_info)
                     )
                 return
-    other_warnings.append(WarningReport(warning_message, important_info))
+    other_warnings.add(WarningReport(warning_message, important_info))
 
 def report_need_page_titles():
     global need_page_titles


Follow ups