@utils.check_messages("<STR_LIT>", "<STR_LIT>")<EOL><INDENT>def visit_excepthandler(self, node):<DEDENT>
def _is_used_in_except_block(node):<EOL><INDENT>scope = node.scope()<EOL>current = node<EOL>while (<EOL>current<EOL>and current != scope<EOL>and not isinstance(current, astroid.ExceptHandler)<EOL>):<EOL><INDENT>current = current.parent<EOL><DEDENT>return isinstance(current, astroid.ExceptHandler) and current.type != node<EOL><DEDENT>if isinstance(node.name, (astroid.Tuple, astroid.List)):<EOL><INDENT>self.add_message("<STR_LIT>", node=node)<EOL>return<EOL><DEDENT>if not node.name:<EOL><INDENT>return<EOL><DEDENT>scope = node.parent.scope()<EOL>scope_names = scope.nodes_of_class(astroid.Name, skip_klass=astroid.FunctionDef)<EOL>scope_names = list(scope_names)<EOL>potential_leaked_names = [<EOL>scope_name<EOL>for scope_name in scope_names<EOL>if scope_name.name == node.name.name<EOL>and scope_name.lineno > node.lineno<EOL>and not _is_used_in_except_block(scope_name)<EOL>]<EOL>reassignments_for_same_name = {<EOL>assign_name.lineno<EOL>for assign_name in scope.nodes_of_class(<EOL>astroid.AssignName, skip_klass=astroid.FunctionDef<EOL>)<EOL>if assign_name.name == node.name.name<EOL>}<EOL>for leaked_name in potential_leaked_names:<EOL><INDENT>if any(<EOL>node.lineno < elem < leaked_name.lineno<EOL>for elem in reassignments_for_same_name<EOL>):<EOL><INDENT>continue<EOL><DEDENT>self.add_message("<STR_LIT>", node=leaked_name)<EOL><DEDENT>
Visit an except handler block and check for exception unpacking.