Patch #1759: Backport of PEP 3129 class decorators
with some help from Georg
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 5764c24..6e52343 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -1498,7 +1498,7 @@
 
 
 /*  compound_stmt:
- *      if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
+ *      if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef | decorated
  */
 static int
 validate_compound_stmt(node *tree)
@@ -1517,7 +1517,8 @@
           || (ntype == for_stmt)
           || (ntype == try_stmt)
           || (ntype == funcdef)
-          || (ntype == classdef))
+          || (ntype == classdef)
+          || (ntype == decorated))
         res = validate_node(tree);
     else {
         res = 0;
@@ -1527,7 +1528,6 @@
     return (res);
 }
 
-
 static int
 validate_yield_or_testlist(node *tree)
 {
@@ -2558,28 +2558,40 @@
 
 /*  funcdef:
  *      
- *            -6   -5    -4         -3  -2 -1
- *  [decorators] 'def' NAME parameters ':' suite
+ *     -5   -4         -3  -2    -1
+ *  'def' NAME parameters ':' suite
  */
 static int
 validate_funcdef(node *tree)
 {
     int nch = NCH(tree);
     int ok = (validate_ntype(tree, funcdef)
-	       && ((nch == 5) || (nch == 6))
+	       && (nch == 5)
 	       && validate_name(RCHILD(tree, -5), "def")
 	       && validate_ntype(RCHILD(tree, -4), NAME)
 	       && validate_colon(RCHILD(tree, -2))
 	       && validate_parameters(RCHILD(tree, -3))
 	       && validate_suite(RCHILD(tree, -1)));
-
-    if (ok && (nch == 6))
-	ok = validate_decorators(CHILD(tree, 0));
-
     return ok;
 }
 
 
+/* decorated
+ *   decorators (classdef | funcdef)
+ */
+static int
+validate_decorated(node *tree)
+{
+  int nch = NCH(tree);
+  int ok = (validate_ntype(tree, decorated)
+	    && (nch == 2)
+	    && validate_decorators(RCHILD(tree, -2))
+	    && (validate_funcdef(RCHILD(tree, -1))
+		|| validate_class(RCHILD(tree, -1)))
+	    );
+  return ok;
+}
+
 static int
 validate_lambdef(node *tree)
 {
@@ -2923,6 +2935,9 @@
           case classdef:
             res = validate_class(tree);
             break;
+	  case decorated:
+	    res = validate_decorated(tree);
+	    break;
             /*
              *  "Trivial" parse tree nodes.
              *  (Why did I call these trivial?)