fix crash when decorators are accessed through more than one dot. Closes #87192

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changesetc0a307bd6161
branchdefault
phasepublic
hiddenno
parent revision#f673b9738dcd epylint: ensure it uses the same python/pylint version. Closes #87024
child revision#65a5679e8a94 d-t-w
files modified by this revision
ChangeLog
checkers/base.py
test/input/func_newstyle_property.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1326984402 -3600
# Thu Jan 19 15:46:42 2012 +0100
# Node ID c0a307bd6161031ceb5a447eb5bd36ee34c83564
# Parent f673b9738dcd6c1f1a458e4763c123f2ad9d607c
fix crash when decorators are accessed through more than one dot. Closes #87192

diff --git a/ChangeLog b/ChangeLog
@@ -1,8 +1,13 @@
1  ChangeLog for PyLint
2  ====================
3 
4 +	--
5 +
6 +    * #87192 fix crash when decorators are accessed through more than one dot
7 +      (for instance @a.b is fine, @a.b.c crash)
8 +
9  2011-12-08  --  0.25.1
10      * #81078: Warn if names in  exception handlers clobber overwrite
11        existing names (patch by tmarek@google.com)
12 
13      * #81113: Fix W0702 messages appearing with the wrong line number.
diff --git a/checkers/base.py b/checkers/base.py
@@ -111,11 +111,11 @@
14          def x(self, value): self._x = value
15      """
16      if node.decorators:
17          for decorator in node.decorators.nodes:
18              if (isinstance(decorator, astng.Getattr) and
19 -                decorator.expr.name == node.name):
20 +                getattr(decorator.expr, 'name', None) == node.name):
21                  return True
22      return False
23 
24  class _BasicChecker(BaseChecker):
25      __implements__ = IASTNGChecker
diff --git a/test/input/func_newstyle_property.py b/test/input/func_newstyle_property.py
@@ -16,10 +16,12 @@
26      method = property(getter, doc='hop')
27 
28      def __init__(self):
29          pass
30 
31 +import logilab.common.decorators
32 +
33  class SomeClass(object):
34      """another docstring"""
35 
36      def __init__(self):
37          self._prop = None
@@ -36,5 +38,11 @@
38 
39      @prop.deleter
40      def prop(self):
41          """I'm the 'prop' property."""
42          del self._prop
43 +
44 +    # test regression
45 +    @logilab.common.decorators.cached
46 +    def noregr(self):
47 +        """used to crash in redefined_by_decorator"""
48 +        return self.prop