diff options
author | Facundo Batista <facundobatista@gmail.com> | 2008-02-25 18:06:00 (GMT) |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2008-02-25 18:06:00 (GMT) |
commit | 4219da4bd0bd46733e6c07ea33c57d45e11641cf (patch) | |
tree | c134c4de7dc6a217c0cb719e555386894fd41e8a /Lib/compiler/ast.py | |
parent | a3c8c10201fb38fb078a4ad2758d945d44c07a5f (diff) | |
download | cpython-4219da4bd0bd46733e6c07ea33c57d45e11641cf.zip cpython-4219da4bd0bd46733e6c07ea33c57d45e11641cf.tar.gz cpython-4219da4bd0bd46733e6c07ea33c57d45e11641cf.tar.bz2 |
Issue 2117. Update compiler module to handle class decorators.
Thanks Thomas Herve
Diffstat (limited to 'Lib/compiler/ast.py')
-rw-r--r-- | Lib/compiler/ast.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py index 93437d6..43b1659 100644 --- a/Lib/compiler/ast.py +++ b/Lib/compiler/ast.py @@ -308,11 +308,12 @@ class CallFunc(Node): return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args)) class Class(Node): - def __init__(self, name, bases, doc, code, lineno=None): + def __init__(self, name, bases, doc, code, decorators = None, lineno=None): self.name = name self.bases = bases self.doc = doc self.code = code + self.decorators = decorators self.lineno = lineno def getChildren(self): @@ -321,16 +322,19 @@ class Class(Node): children.extend(flatten(self.bases)) children.append(self.doc) children.append(self.code) + children.append(self.decorators) return tuple(children) def getChildNodes(self): nodelist = [] nodelist.extend(flatten_nodes(self.bases)) nodelist.append(self.code) + if self.decorators is not None: + nodelist.append(self.decorators) return tuple(nodelist) def __repr__(self): - return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code)) + return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators)) class Compare(Node): def __init__(self, expr, ops, lineno=None): |