summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-08-21 21:42:18 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-08-21 21:42:18 +0300
commit489e01057de4028887af7b6842621914816abea5 (patch)
tree9e8ef0eb4d86a1bc0224f852b44a20c22032a382 /pylint
parent69f806375f8d7a3f17722e8140f30b2e354d9aa6 (diff)
parentae543c3cbfba95eed9aad431737dfd1931446d19 (diff)
downloadpylint-489e01057de4028887af7b6842621914816abea5.tar.gz
Merged in renezhang/pylint_raise_error (pull request #267)
Fix index out of range when handling raise()
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/exceptions.py2
-rw-r--r--pylint/test/unittest_checker_exceptions.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py
index f40c2aa..9020d5f 100644
--- a/pylint/checkers/exceptions.py
+++ b/pylint/checkers/exceptions.py
@@ -194,7 +194,7 @@ class ExceptionsChecker(BaseChecker):
isinstance(expr, (astroid.List, astroid.Dict, astroid.Tuple,
astroid.Module, astroid.Function))):
emit = True
- if not PY3K and isinstance(expr, astroid.Tuple):
+ if not PY3K and isinstance(expr, astroid.Tuple) and expr.elts:
# On Python 2, using the following is not an error:
# raise (ZeroDivisionError, None)
# raise (ZeroDivisionError, )
diff --git a/pylint/test/unittest_checker_exceptions.py b/pylint/test/unittest_checker_exceptions.py
index 890e7c8..2903691 100644
--- a/pylint/test/unittest_checker_exceptions.py
+++ b/pylint/test/unittest_checker_exceptions.py
@@ -50,6 +50,7 @@ class ExceptionsCheckerTest(CheckerTestCase):
raise (something, None) #@
raise (4, None) #@
+ raise () #@
''')
with self.assertNoMessages():
self.checker.visit_raise(nodes[0])
@@ -59,6 +60,9 @@ class ExceptionsCheckerTest(CheckerTestCase):
message = Message('raising-bad-type', node=nodes[2], args='tuple')
with self.assertAddsMessages(message):
self.checker.visit_raise(nodes[2])
+ message = Message('raising-bad-type', node=nodes[3], args='tuple')
+ with self.assertAddsMessages(message):
+ self.checker.visit_raise(nodes[3])
if __name__ == '__main__':