diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-20 09:15:28 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-20 09:15:28 +0200 |
commit | 646952800ebbdcebfc4f899cce29114dff65949a (patch) | |
tree | 3a83d9d4f4afaa4d8286b911b817f29744ad5418 | |
parent | c0ceabe1ee0904477ed0b0b9371ae43915d7bd2f (diff) | |
download | cython-646952800ebbdcebfc4f899cce29114dff65949a.tar.gz |
Minor code cleanup.
-rw-r--r-- | Cython/Compiler/Nodes.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 84654bf12..73baa9ee0 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2885,13 +2885,16 @@ class DefNode(FuncDefNode): # staticmethod() was overridden - not much we can do here ... self.is_staticmethod = False - if self.name == '__new__' and env.is_py_class_scope: - self.is_staticmethod = True - if not self.is_classmethod and self.name in IMPLICIT_CLASSMETHODS and env.is_py_class_scope: - from .ExprNodes import NameNode - self.decorators = self.decorators or [] - self.decorators.insert(0, DecoratorNode(self.pos, decorator=NameNode(self.pos, name=EncodedString('classmethod')))) - self.is_classmethod = True + if env.is_py_class_scope: + if self.name == '__new__': + self.is_staticmethod = True + elif not self.is_classmethod and self.name in IMPLICIT_CLASSMETHODS: + self.is_classmethod = True + # TODO: remove the need to generate a real decorator here, is_classmethod=True should suffice. + from .ExprNodes import NameNode + self.decorators = self.decorators or [] + self.decorators.insert(0, DecoratorNode( + self.pos, decorator=NameNode(self.pos, name=EncodedString('classmethod')))) self.analyse_argument_types(env) if self.name == '<lambda>': |