From 931b8d94bf6eabcf42785bf01621035ebb022748 Mon Sep 17 00:00:00 2001
From: Vitja Makarov <vitja.makarov@gmail.com>
Date: Thu, 26 May 2011 23:34:29 +0400
Subject: [PATCH] Move message reporting to MessageCollection

---
 Cython/Compiler/FlowControl.py | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/Cython/Compiler/FlowControl.py b/Cython/Compiler/FlowControl.py
index a84bc74af..b9dd5a777 100644
--- a/Cython/Compiler/FlowControl.py
+++ b/Cython/Compiler/FlowControl.py
@@ -394,20 +394,24 @@ class GV(object):
         fp.write(' }\n')
 
 
-class MessageCollection(list):
+class MessageCollection:
     """Collect error/warnings messages first then sort"""
+    def __init__(self):
+        self.messages = []
 
     def error(self, pos, message):
-        self.append((pos, True, message))
+        self.messages.append((pos, True, message))
 
     def warning(self, pos, message):
-        self.append((pos, False, message))
-
-    def _key(self, item):
-        return item[0]
+        self.messages.append((pos, False, message))
 
-    def sort(self):
-        list.sort(self, key=self._key)
+    def report(self):
+        self.messages.sort()
+        for pos, is_error, message in self.messages:
+            if is_error:
+                error(pos, message)
+            else:
+                warning(pos, message, 2)
 
 
 def check_definitions(flow, compiler_directives):
@@ -524,13 +528,7 @@ def check_definitions(flow, compiler_directives):
                     messages.warning(entry.pos, "Unused entry '%s'" % entry.name)
                 entry.cf_used = False
 
-    # Sort warnings by position
-    messages.sort()
-    for pos, is_error, message in messages:
-        if is_error:
-            error(pos, message)
-        else:
-            warning(pos, message, 2)
+    messages.report()
 
 
 class AssignmentCollector(TreeVisitor):
-- 
2.30.9