summaryrefslogtreecommitdiff
path: root/checkers/base.py
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-04-25 13:17:17 +0300
committercpopa <devnull@localhost>2014-04-25 13:17:17 +0300
commita1bf229f85aa0285f8a963f46109a06520a60ea7 (patch)
treeb1fcdefc4aec24892a0abe700422fc4c5337f3f9 /checkers/base.py
parent5a130703e1a1f23bc5f80294527299675de1293e (diff)
downloadpylint-a1bf229f85aa0285f8a963f46109a06520a60ea7.tar.gz
Fix a potential AttributeError when checking for `reversed` arguments.
Diffstat (limited to 'checkers/base.py')
-rw-r--r--checkers/base.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/checkers/base.py b/checkers/base.py
index ac58177..8136d0f 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -785,11 +785,14 @@ functions, methods
if argument is None:
# nothing was infered
# try to see if we have iter()
- if (isinstance(node.args[0], astroid.CallFunc) and
- node.args[0].func.name == 'iter'):
- func = node.args[0].func.infer().next()
- if is_builtin_object(func):
- self.add_message('bad-reversed-sequence', node=node)
+ if isinstance(node.args[0], astroid.CallFunc):
+ try:
+ func = node.args[0].func.infer().next()
+ except InferenceError:
+ return
+ if (getattr(func, 'name', None) == 'iter' and
+ is_builtin_object(func)):
+ self.add_message('bad-reversed-sequence', node=node)
return
if isinstance(argument, astroid.Instance):