def visit_tryfinally(self, node, parent): """visit a TryFinally node by returning a fresh instance of it""" newnode = new.TryFinally() self._set_infos(node, newnode, parent) newnode.body = [self.visit(child, newnode) for child in node.body.nodes] newnode.finalbody = [self.visit(n, newnode) for n in node.final.nodes] return newnode
def visit_tryfinally(self, node, parent): """visit a TryFinally node by returning a fresh instance of it""" newnode = new.TryFinally() _lineno_parent(node, newnode, parent) newnode.body = [self.visit(child, newnode) for child in node.body] newnode.finalbody = [self.visit(n, newnode) for n in node.finalbody] newnode.set_line_info(newnode.last_child()) return newnode
def visit_try(self, node, parent): # python 3.3 introduce a new Try node replacing TryFinally/TryExcept nodes if node.finalbody: newnode = new.TryFinally() _lineno_parent(node, newnode, parent) newnode.finalbody = [self.visit(n, newnode) for n in node.finalbody] if node.handlers: excnode = new.TryExcept() _lineno_parent(node, excnode, parent) excnode.body = [self.visit(child, newnode) for child in node.body] excnode.handlers = [self.visit(child, newnode) for child in node.handlers] excnode.orelse = [self.visit(child, newnode) for child in node.orelse] newnode.body = [excnode] else: newnode.body = [self.visit(child, newnode) for child in node.body] elif node.handlers: newnode = new.TryExcept() _lineno_parent(node, newnode, parent) newnode.body = [self.visit(child, newnode) for child in node.body] newnode.handlers = [self.visit(child, newnode) for child in node.handlers] newnode.orelse = [self.visit(child, newnode) for child in node.orelse] newnode.set_line_info(newnode.last_child()) return newnode