summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-20 09:15:28 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-20 09:15:28 +0200
commit646952800ebbdcebfc4f899cce29114dff65949a (patch)
tree3a83d9d4f4afaa4d8286b911b817f29744ad5418
parentc0ceabe1ee0904477ed0b0b9371ae43915d7bd2f (diff)
downloadcython-646952800ebbdcebfc4f899cce29114dff65949a.tar.gz
Minor code cleanup.
-rw-r--r--Cython/Compiler/Nodes.py17
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>':