[Python-checkins] r47069 - python/trunk/Lib/compiler/transformer.py

georg.brandl python-checkins at python.org
Thu Jun 22 16:46:18 CEST 2006


Author: georg.brandl
Date: Thu Jun 22 16:46:17 2006
New Revision: 47069

Modified:
   python/trunk/Lib/compiler/transformer.py
Log:
Set lineno correctly on list, tuple and dict literals.



Modified: python/trunk/Lib/compiler/transformer.py
==============================================================================
--- python/trunk/Lib/compiler/transformer.py	(original)
+++ python/trunk/Lib/compiler/transformer.py	Thu Jun 22 16:46:17 2006
@@ -727,17 +727,17 @@
 
     def atom_lpar(self, nodelist):
         if nodelist[1][0] == token.RPAR:
-            return Tuple(())
+            return Tuple((), lineno=nodelist[0][2])
         return self.com_node(nodelist[1])
 
     def atom_lsqb(self, nodelist):
         if nodelist[1][0] == token.RSQB:
-            return List(())
+            return List((), lineno=nodelist[0][2])
         return self.com_list_constructor(nodelist[1])
 
     def atom_lbrace(self, nodelist):
         if nodelist[1][0] == token.RBRACE:
-            return Dict(())
+            return Dict((), lineno=nodelist[0][2])
         return self.com_dictmaker(nodelist[1])
 
     def atom_backquote(self, nodelist):
@@ -1141,7 +1141,7 @@
             values = []
             for i in range(1, len(nodelist), 2):
                 values.append(self.com_node(nodelist[i]))
-            return List(values)
+            return List(values, lineno=values[0].lineno)
 
     if hasattr(symbol, 'gen_for'):
         def com_generator_expression(self, expr, node):
@@ -1188,7 +1188,7 @@
         for i in range(1, len(nodelist), 4):
             items.append((self.com_node(nodelist[i]),
                           self.com_node(nodelist[i+2])))
-        return Dict(items)
+        return Dict(items, lineno=items[0][0].lineno)
 
     def com_apply_trailer(self, primaryNode, nodelist):
         t = nodelist[1][0]


More information about the Python-checkins mailing list