diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2012-01-19 15:46:42 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2012-01-19 15:46:42 +0100 |
commit | 281e4e1819447d31b366dfc3ace4e4bedd77aeb7 (patch) | |
tree | 46858590001ef9aefd849792742c5d4385d3dc2e | |
parent | c8e20f7f0568a1eee1e4d62f86abe0ce1d88a14a (diff) | |
download | pylint-git-281e4e1819447d31b366dfc3ace4e4bedd77aeb7.tar.gz |
fix crash when decorators are accessed through more than one dot. Closes #87192
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | checkers/base.py | 2 | ||||
-rw-r--r-- | test/input/func_newstyle_property.py | 8 |
3 files changed, 14 insertions, 1 deletions
@@ -1,6 +1,11 @@ ChangeLog for PyLint ==================== + -- + + * #87192 fix crash when decorators are accessed through more than one dot + (for instance @a.b is fine, @a.b.c crash) + 2011-12-08 -- 0.25.1 * #81078: Warn if names in exception handlers clobber overwrite existing names (patch by tmarek@google.com) diff --git a/checkers/base.py b/checkers/base.py index 2062ae279..c551a3576 100644 --- a/checkers/base.py +++ b/checkers/base.py @@ -113,7 +113,7 @@ def redefined_by_decorator(node): if node.decorators: for decorator in node.decorators.nodes: if (isinstance(decorator, astng.Getattr) and - decorator.expr.name == node.name): + getattr(decorator.expr, 'name', None) == node.name): return True return False diff --git a/test/input/func_newstyle_property.py b/test/input/func_newstyle_property.py index a89c00b05..2b8d60bfd 100644 --- a/test/input/func_newstyle_property.py +++ b/test/input/func_newstyle_property.py @@ -18,6 +18,8 @@ class HaNonNonNon: def __init__(self): pass +import logilab.common.decorators + class SomeClass(object): """another docstring""" @@ -38,3 +40,9 @@ class SomeClass(object): def prop(self): """I'm the 'prop' property.""" del self._prop + + # test regression + @logilab.common.decorators.cached + def noregr(self): + """used to crash in redefined_by_decorator""" + return self.prop |