Set lineno correctly on list, tuple and dict literals.

This commit is contained in:
Georg Brandl 2006-06-22 14:46:17 +00:00
parent f6a84f5615
commit c3f49ca558
1 changed files with 5 additions and 5 deletions

View File

@ -727,17 +727,17 @@ class Transformer:
def atom_lpar(self, nodelist): def atom_lpar(self, nodelist):
if nodelist[1][0] == token.RPAR: if nodelist[1][0] == token.RPAR:
return Tuple(()) return Tuple((), lineno=nodelist[0][2])
return self.com_node(nodelist[1]) return self.com_node(nodelist[1])
def atom_lsqb(self, nodelist): def atom_lsqb(self, nodelist):
if nodelist[1][0] == token.RSQB: if nodelist[1][0] == token.RSQB:
return List(()) return List((), lineno=nodelist[0][2])
return self.com_list_constructor(nodelist[1]) return self.com_list_constructor(nodelist[1])
def atom_lbrace(self, nodelist): def atom_lbrace(self, nodelist):
if nodelist[1][0] == token.RBRACE: if nodelist[1][0] == token.RBRACE:
return Dict(()) return Dict((), lineno=nodelist[0][2])
return self.com_dictmaker(nodelist[1]) return self.com_dictmaker(nodelist[1])
def atom_backquote(self, nodelist): def atom_backquote(self, nodelist):
@ -1141,7 +1141,7 @@ class Transformer:
values = [] values = []
for i in range(1, len(nodelist), 2): for i in range(1, len(nodelist), 2):
values.append(self.com_node(nodelist[i])) values.append(self.com_node(nodelist[i]))
return List(values) return List(values, lineno=values[0].lineno)
if hasattr(symbol, 'gen_for'): if hasattr(symbol, 'gen_for'):
def com_generator_expression(self, expr, node): def com_generator_expression(self, expr, node):
@ -1188,7 +1188,7 @@ class Transformer:
for i in range(1, len(nodelist), 4): for i in range(1, len(nodelist), 4):
items.append((self.com_node(nodelist[i]), items.append((self.com_node(nodelist[i]),
self.com_node(nodelist[i+2]))) self.com_node(nodelist[i+2])))
return Dict(items) return Dict(items, lineno=items[0][0].lineno)
def com_apply_trailer(self, primaryNode, nodelist): def com_apply_trailer(self, primaryNode, nodelist):
t = nodelist[1][0] t = nodelist[1][0]