def _redefines_import(node):
 current = node
 while (current and (not isinstance(current.parent, astroid.ExceptHandler))):
  current = current.parent
 if ((not current) or (not is_import_error(current.parent))):
  return False
 try_block = current.parent.parent
 for import_node in try_block.nodes_of_class((astroid.From, astroid.Import)):
  for (name, alias) in import_node.names:
   if alias:
    if (alias == node.name):
     return True
   elif (name == node.name):
    return True
 return False

def _redefines_import ( node ) : current = node while ( current and ( not isinstance ( current . parent , astroid . ExceptHandler ) ) ) : current = current . parent if ( ( not current ) or ( not is_import_error ( current . parent ) ) ) : return False try_block = current . parent . parent for import_node in try_block . nodes_of_class ( ( astroid . From , astroid . Import ) ) : for ( name , alias ) in import_node . names : if alias : if ( alias == node . name ) : return True elif ( name == node . name ) : return True return False
detect that the given node is inside an exception handler and redefines an import from the tryexcept body .