From 1936745668f44dd121b50fef31a70efc07cc4ebf Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Wed, 29 Aug 2001 20:57:43 +0000 Subject: [PATCH] Generate SET_LINENO for list and tuple literals when the open paren starts a new line. Also fix undetected typo in visitDict() -- uncovered by recent change to add lineno attrs to atoms. --- Lib/compiler/pycodegen.py | 4 +++- Tools/compiler/compiler/pycodegen.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index b0bddb71a84..07c82f7f382 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -953,11 +953,13 @@ class CodeGenerator: self.emit('LOAD_CONST', Ellipsis) def visitTuple(self, node): + self.set_lineno(node) for elt in node.nodes: self.visit(elt) self.emit('BUILD_TUPLE', len(node.nodes)) def visitList(self, node): + self.set_lineno(node) for elt in node.nodes: self.visit(elt) self.emit('BUILD_LIST', len(node.nodes)) @@ -970,7 +972,7 @@ class CodeGenerator: def visitDict(self, node): lineno = getattr(node, 'lineno', None) if lineno: - set.emit('SET_LINENO', lineno) + self.emit('SET_LINENO', lineno) self.emit('BUILD_MAP', 0) for k, v in node.items: lineno2 = getattr(node, 'lineno', None) diff --git a/Tools/compiler/compiler/pycodegen.py b/Tools/compiler/compiler/pycodegen.py index b0bddb71a84..07c82f7f382 100644 --- a/Tools/compiler/compiler/pycodegen.py +++ b/Tools/compiler/compiler/pycodegen.py @@ -953,11 +953,13 @@ class CodeGenerator: self.emit('LOAD_CONST', Ellipsis) def visitTuple(self, node): + self.set_lineno(node) for elt in node.nodes: self.visit(elt) self.emit('BUILD_TUPLE', len(node.nodes)) def visitList(self, node): + self.set_lineno(node) for elt in node.nodes: self.visit(elt) self.emit('BUILD_LIST', len(node.nodes)) @@ -970,7 +972,7 @@ class CodeGenerator: def visitDict(self, node): lineno = getattr(node, 'lineno', None) if lineno: - set.emit('SET_LINENO', lineno) + self.emit('SET_LINENO', lineno) self.emit('BUILD_MAP', 0) for k, v in node.items: lineno2 = getattr(node, 'lineno', None)