Fix precedence rules of decorator options.
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 5 Aug 2008 12:38:44 +0000 (14:38 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 5 Aug 2008 12:38:44 +0000 (14:38 +0200)
Cython/Compiler/ParseTreeTransforms.py
tests/run/bufaccess.pyx

index 6979ee36bcd19041d6bea6c236174433ae0436e8..983c2b99cfc233ad1eacf68e9a57baaf6e01614b 100644 (file)
@@ -330,20 +330,17 @@ class ResolveOptions(CythonTransform):
             return None
 
     def visit_with_options(self, node, options):
-        if not options:
-            return self.visit_Node(node)
-        else:
-            oldoptions = self.options
-            newoptions = copy.copy(oldoptions)
-            newoptions.update(options)
-            self.options = newoptions
-            node = self.visit_Node(node)
-            self.options = oldoptions
+        oldoptions = self.options
+        newoptions = copy.copy(oldoptions)
+        newoptions.update(options)
+        self.options = newoptions
+        node = self.visit_Node(node)
+        self.options = oldoptions
         return node  
  
     # Handle decorators
     def visit_DefNode(self, node):
-        options = {}
+        options = []
         
         if node.decorators:
             # Split the decorators into two lists -- real decorators and options
@@ -351,14 +348,21 @@ class ResolveOptions(CythonTransform):
             for dec in node.decorators:
                 option = self.try_to_parse_option(dec.decorator)
                 if option is not None:
-                    name, value = option
-                    options[name] = value
+                    options.append(option)
                 else:
                     realdecs.append(dec)
             node.decorators = realdecs
 
-        return self.visit_with_options(node, options)
-
+        if options:
+            optdict = {}
+            options.reverse() # Decorators coming first take precedence
+            for option in options:
+                name, value = option
+                optdict[name] = value
+            return self.visit_with_options(node, options)
+        else:
+            return self.visit_Node(node)
+                                   
     # Handle with statements
     def visit_WithStatNode(self, node):
         option = self.try_to_parse_option(node.manager)
index c5b4c2a855dda89db1f2fbb00735a31a6c895f3e..e5b6b4f5664dd59c1ad5986f1597f94b9e3c0b84 100644 (file)
@@ -543,6 +543,7 @@ def safe_get(object[int] buf, int idx):
 
 @testcase
 @cython.boundscheck(False)
+@cython.boundscheck(True)
 def unsafe_get(object[int] buf, int idx):
     """
     Access outside of the area the buffer publishes.