From 0722bb267e8c969a4f742377f09779d74c3657ee Mon Sep 17 00:00:00 2001
From: Stefan Behnel <scoder@users.berlios.de>
Date: Sat, 30 Oct 2010 14:39:54 +0200
Subject: [PATCH] allow decorators on classes in the parser, just disable them
 on cdef classes later on

---
 Cython/Compiler/ParseTreeTransforms.py | 12 +++++++-----
 Cython/Compiler/Parsing.py             |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index 17bfb3f66..9e1692471 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -929,9 +929,8 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
         return self._handle_decorators(
             func_node, func_node.name)
 
-    def _visit_CClassDefNode(self, class_node):
-        # This doesn't currently work, so it's disabled (also in the
-        # parser).
+    def visit_CClassDefNode(self, class_node):
+        # This doesn't currently work, so it's disabled.
         #
         # Problem: assignments to cdef class names do not work.  They
         # would require an additional check anyway, as the extension
@@ -941,8 +940,11 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
         self.visitchildren(class_node)
         if not class_node.decorators:
             return class_node
-        return self._handle_decorators(
-            class_node, class_node.class_name)
+        error(class_node.pos,
+              "Decorators not allowed on cdef classes (used on type '%s')" % class_node.class_name)
+        return class_node
+        #return self._handle_decorators(
+        #    class_node, class_node.class_name)
 
     def visit_ClassDefNode(self, class_node):
         self.visitchildren(class_node)
diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
index 4903bd6ba..8df5ca102 100644
--- a/Cython/Compiler/Parsing.py
+++ b/Cython/Compiler/Parsing.py
@@ -1681,8 +1681,8 @@ def p_statement(s, ctx, first_statement = 0):
         s.level = ctx.level
         node = p_cdef_statement(s, ctx(overridable = overridable))
         if decorators is not None:
-            if not isinstance(node, (Nodes.CFuncDefNode, Nodes.CVarDefNode)):
-                s.error("Decorators can only be followed by functions or Python classes")
+            if not isinstance(node, (Nodes.CFuncDefNode, Nodes.CVarDefNode, Nodes.CClassDefNode)):
+                s.error("Decorators can only be followed by functions or classes")
             node.decorators = decorators
         return node
     else:
-- 
2.30.9