diff options
author | cpopa <devnull@localhost> | 2014-04-25 13:17:17 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-04-25 13:17:17 +0300 |
commit | a1bf229f85aa0285f8a963f46109a06520a60ea7 (patch) | |
tree | b1fcdefc4aec24892a0abe700422fc4c5337f3f9 /checkers/base.py | |
parent | 5a130703e1a1f23bc5f80294527299675de1293e (diff) | |
download | pylint-a1bf229f85aa0285f8a963f46109a06520a60ea7.tar.gz |
Fix a potential AttributeError when checking for `reversed` arguments.
Diffstat (limited to 'checkers/base.py')
-rw-r--r-- | checkers/base.py | 13 |
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): |