Commits

Ali Gholami Rudi  committed 588fc39

pyobjectsdef: fixed using FunctionDef.decorator_list

  • Participants
  • Parent commits 0bae88a

Comments (0)

Files changed (2)

File rope/base/pyobjectsdef.py

 
     @property
     def decorators(self):
-        if hasattr(self.ast_node, 'decorator_list'):
-            return self.ast_node.decorators
-        return self.ast_node.decorators
+        try:
+            return getattr(self.ast_node, 'decorator_list')
+        except AttributeError:
+            return getattr(self.ast_node, 'decorators', None)
 
 
 class PyClass(pyobjects.PyClass):

File rope/refactor/patchedast.py

 
     def _FunctionDef(self, node):
         children = []
-        decorators = getattr(node, 'decorator_list',
-                             getattr(node, 'decorators'))
+        try:
+            decorators = getattr(node, 'decorator_list')
+        except AttributeError:
+            decorators = getattr(node, 'decorators', None)
         if decorators:
             for decorator in decorators:
                 children.append('@')