def visit_try(self, node, parent, assign_ctx=None): # python 3.3 introduce a new Try node replacing TryFinally/TryExcept nodes # pylint: disable=redefined-variable-type if node.finalbody: newnode = new.TryFinally() _lineno_parent(node, newnode, parent) newnode.finalbody = [self.visit(n, newnode, assign_ctx) for n in node.finalbody] if node.handlers: excnode = new.TryExcept() _lineno_parent(node, excnode, newnode) excnode.body = [self.visit(child, excnode, assign_ctx) for child in node.body] excnode.handlers = [self.visit(child, excnode, assign_ctx) for child in node.handlers] excnode.orelse = [self.visit(child, excnode, assign_ctx) for child in node.orelse] newnode.body = [excnode] else: newnode.body = [self.visit(child, newnode, assign_ctx) for child in node.body] elif node.handlers: newnode = new.TryExcept() _lineno_parent(node, newnode, parent) newnode.body = [self.visit(child, newnode, assign_ctx) for child in node.body] newnode.handlers = [self.visit(child, newnode, assign_ctx) for child in node.handlers] newnode.orelse = [self.visit(child, newnode, assign_ctx) for child in node.orelse] return newnode
def visit_tryexcept(self, node, parent): """visit a TryExcept node by returning a fresh instance of it""" newnode = nodes.TryExcept(node.lineno, node.col_offset, parent) newnode.postinit( [self.visit(child, newnode) for child in node.body], [self.visit(child, newnode) for child in node.handlers], [self.visit(child, newnode) for child in node.orelse]) return newnode
def visit_tryexcept(self, node, parent): """visit a TryExcept node by returning a fresh instance of it""" 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] 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, newnode) excnode.body = [self.visit(child, excnode) for child in node.body] excnode.handlers = [self.visit(child, excnode) for child in node.handlers] excnode.orelse = [self.visit(child, excnode) 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] return newnode
def visit_tryexcept(self, node, parent): """visit a TryExcept node by returning a fresh instance of it""" newnode = nodes.TryExcept(node.lineno, node.col_offset, parent) body = nodes.Block( 'body', [self.visit(child, newnode) for child in node.body], newnode) handlers = [self.visit(child, newnode) for child in node.handlers] orelse = nodes.Block( 'orelse', [self.visit(child, newnode) for child in node.orelse], newnode) newnode.postinit(body, handlers, orelse) return newnode