summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--checkers/exceptions.py12
-rw-r--r--checkers/python3.py14
2 files changed, 14 insertions, 12 deletions
diff --git a/checkers/exceptions.py b/checkers/exceptions.py
index a99f214f4..67f6ce54e 100644
--- a/checkers/exceptions.py
+++ b/checkers/exceptions.py
@@ -117,12 +117,6 @@ MSGS = {
'Used when the exception to catch is of the form \
"except A or B:". If intending to catch multiple, \
rewrite as "except (A, B):"'),
- 'W0712': ('Implicit unpacking of exceptions is not supported in Python 3',
- 'unpacking-in-except',
- 'Python3 will not allow implicit unpacking of exceptions in except '
- 'clauses. '
- 'See http://www.python.org/dev/peps/pep-3110/',
- {'maxversion': (3, 0)}),
}
@@ -221,12 +215,6 @@ class ExceptionsChecker(BaseChecker):
value_found = False
return value_found
- @check_messages('unpacking-in-except')
- def visit_excepthandler(self, node):
- """Visit an except handler block and check for exception unpacking."""
- if isinstance(node.name, (astroid.Tuple, astroid.List)):
- self.add_message('unpacking-in-except', node=node)
-
@check_messages('bare-except', 'broad-except', 'pointless-except',
'binary-op-exception', 'bad-except-order',
'catching-non-exception')
diff --git a/checkers/python3.py b/checkers/python3.py
index 0b344dace..a8d66f7eb 100644
--- a/checkers/python3.py
+++ b/checkers/python3.py
@@ -49,6 +49,14 @@ class Python3Checker(checkers.BaseChecker):
'Used when parameter unpacking is specified for a function'
"(Python 3 doesn't allow it)",
{'maxversion': (3, 0)}),
+ 'E1603': ('Implicit unpacking of exceptions is not supported '
+ 'in Python 3',
+ 'unpacking-in-except',
+ 'Python3 will not allow implicit unpacking of '
+ 'exceptions in except clauses. '
+ 'See http://www.python.org/dev/peps/pep-3110/',
+ {'maxversion': (3, 0),
+ 'old_names': [('W0712', 'unpacking-in-except')]}),
'W1601': ('apply built-in referenced',
'apply-builtin',
'Used when the apply built-in function is referenced '
@@ -286,6 +294,12 @@ class Python3Checker(checkers.BaseChecker):
except astroid.InferenceError:
return
+ @utils.check_messages('unpacking-in-except')
+ def visit_excepthandler(self, node):
+ """Visit an except handler block and check for exception unpacking."""
+ if isinstance(node.name, (astroid.Tuple, astroid.List)):
+ self.add_message('unpacking-in-except', node=node)
+
def register(linter):
linter.register_checker(Python3Checker(linter))