summaryrefslogtreecommitdiff
path: root/node_classes.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2014-08-26 22:27:41 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2014-08-26 22:27:41 +0300
commit0cbbebe7328ae8df3a77e9481059d2ac7f673b0a (patch)
treef432a6918d5fbc892c09ae4db05041e3795f415d /node_classes.py
parentdbe95f9ad77e523a126d9d4ce8d92e752a738fb7 (diff)
downloadastroid-git-0cbbebe7328ae8df3a77e9481059d2ac7f673b0a.tar.gz
Fix a maximum recursion error occured during the inference, where statements with the same name weren't filtered properly. Closes pylint issue #295.
Diffstat (limited to 'node_classes.py')
-rw-r--r--node_classes.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/node_classes.py b/node_classes.py
index 6d597458..b92fc247 100644
--- a/node_classes.py
+++ b/node_classes.py
@@ -146,6 +146,20 @@ class LookupMixIn(object):
myframe = self.frame().parent.frame()
else:
myframe = self.frame()
+ # If the frame of this node is the same as the statement
+ # of this node, then the node is part of a class or
+ # a function definition and the frame of this node should be the
+ # the upper frame, not the frame of the definition.
+ # For more information why this is important,
+ # see Pylint issue #295.
+ # For example, for 'b', the statement is the same
+ # as the frame / scope:
+ #
+ # def test(b=1):
+ # ...
+
+ if self.statement() is myframe and myframe.parent:
+ myframe = myframe.parent.frame()
if not myframe is frame or self is frame:
return stmts
mystmt = self.statement()