summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-02-23 15:01:05 +0000
committerChristian Heimes <christian@cheimes.de>2008-02-23 15:01:05 +0000
commit5224d28d38eb784f17c2fed3f48368285df6d17a (patch)
treeb258202efc39ae5239d91dcf5b1898c6ce713f16 /Python/compile.c
parentb12f0b581a6f268d0611c87012d1273aeca220b8 (diff)
downloadcpython-git-5224d28d38eb784f17c2fed3f48368285df6d17a.tar.gz
Patch #1759: Backport of PEP 3129 class decorators
with some help from Georg
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 8ae56159e1..f02c81acd6 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1362,7 +1362,7 @@ compiler_function(struct compiler *c, stmt_ty s)
PyCodeObject *co;
PyObject *first_const = Py_None;
arguments_ty args = s->v.FunctionDef.args;
- asdl_seq* decos = s->v.FunctionDef.decorators;
+ asdl_seq* decos = s->v.FunctionDef.decorator_list;
stmt_ty st;
int i, n, docstring;
@@ -1413,9 +1413,14 @@ compiler_function(struct compiler *c, stmt_ty s)
static int
compiler_class(struct compiler *c, stmt_ty s)
{
- int n;
+ int n, i;
PyCodeObject *co;
PyObject *str;
+ asdl_seq* decos = s->v.ClassDef.decorator_list;
+
+ if (!compiler_decorators(c, decos))
+ return 0;
+
/* push class name on stack, needed by BUILD_CLASS */
ADDOP_O(c, LOAD_CONST, s->v.ClassDef.name, consts);
/* push the tuple of base classes on the stack */
@@ -1461,6 +1466,10 @@ compiler_class(struct compiler *c, stmt_ty s)
ADDOP_I(c, CALL_FUNCTION, 0);
ADDOP(c, BUILD_CLASS);
+ /* apply decorators */
+ for (i = 0; i < asdl_seq_LEN(decos); i++) {
+ ADDOP_I(c, CALL_FUNCTION, 1);
+ }
if (!compiler_nameop(c, s->v.ClassDef.name, Store))
return 0;
return 1;