Commit 6b692963 authored by Vitja Makarov's avatar Vitja Makarov

Make decorators an attribute of PyClassDefNode

parent a31a76c4
...@@ -3793,7 +3793,7 @@ class PyClassDefNode(ClassDefNode): ...@@ -3793,7 +3793,7 @@ class PyClassDefNode(ClassDefNode):
# target NameNode Variable to assign class object to # target NameNode Variable to assign class object to
child_attrs = ["body", "dict", "metaclass", "mkw", "bases", "class_result", child_attrs = ["body", "dict", "metaclass", "mkw", "bases", "class_result",
"target", "class_cell"] "target", "class_cell", "decorators"]
decorators = None decorators = None
class_result = None class_result = None
py3_style_class = False # Python3 style class (bases+kwargs) py3_style_class = False # Python3 style class (bases+kwargs)
...@@ -3910,6 +3910,7 @@ class PyClassDefNode(ClassDefNode): ...@@ -3910,6 +3910,7 @@ class PyClassDefNode(ClassDefNode):
decorator.pos, decorator.pos,
function = decorator.decorator, function = decorator.decorator,
args = [class_result]) args = [class_result])
self.decorators = None
self.class_result = class_result self.class_result = class_result
self.class_result.analyse_declarations(env) self.class_result.analyse_declarations(env)
self.target.analyse_target_declaration(env) self.target.analyse_target_declaration(env)
......
# mode: run
# tag: decorator, lambda
def decorate(f):
return f
@decorate(lambda x: x)
class TestClassDecorator(object):
"""
>>> obj = TestClassDecorator()
>>> obj.hello()
'Hello, world!'
"""
def hello(self):
return "Hello, world!"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment