def visit_discard(self, node, parent): """visit a Discard node by returning a fresh instance of it""" newnode = new.Discard() _lineno_parent(node, newnode, parent) newnode.value = self.visit(node.value, newnode) newnode.set_line_info(newnode.last_child()) return newnode
def _check_discard(self, node, parent): """check if we introduced already a discard node.""" # XXX we should maybe use something else then 'asscontext' here if self.asscontext is None: self.asscontext = 'Dis' newnode = new.Discard() self._set_infos(node, newnode, parent) newnode.value = self.visit(node, newnode) self.asscontext = None return newnode return False
def visit_discard(self, node, parent): """visit a Discard node by returning a fresh instance of it""" newnode = new.Discard() if node.lineno is None: # ignore dummy Discard introduced when a statement # is ended by a semi-colon: remove it at the end of rebuilding self._remove_nodes.append((newnode, parent)) self._set_infos(node, newnode, parent) self.asscontext = "Dis" newnode.value = self.visit(node.expr, newnode) self.asscontext = None return newnode
def visit_discard(self, node, parent): """visit a Discard node by returning a fresh instance of it""" newnode = new.Discard() if sys.version_info >= (2, 4) and node.lineno is None: # ignore dummy Discard introduced when a statement # is ended by a semi-colon: remove it at the end of rebuilding # however, it does also happen in regular Discard nodes on 2.3 self._remove_nodes.append((newnode, parent)) self._set_infos(node, newnode, parent) self.asscontext = "Dis" newnode.value = self.visit(node.expr, newnode) self.asscontext = None return newnode