[pypy-svn] r18642 - in pypy/dist/pypy/interpreter: pyparser/test stablecompiler

ac at codespeak.net ac at codespeak.net
Sat Oct 15 17:51:21 CEST 2005


Author: ac
Date: Sat Oct 15 17:51:21 2005
New Revision: 18642

Modified:
   pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
   pypy/dist/pypy/interpreter/stablecompiler/transformer.py
Log:
Set correct lineno on List-nodes and re-enable test for it.


Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py	(original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py	Sat Oct 15 17:51:21 2005
@@ -683,7 +683,7 @@
     'snippet_whitespaces.py',
     'snippet_samples.py',
     'snippet_decorators.py',
-    # 'snippet_listlinenos.py',
+    'snippet_listlinenos.py',
     'snippet_whilelineno.py',
     ]
 

Modified: pypy/dist/pypy/interpreter/stablecompiler/transformer.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/transformer.py	(original)
+++ pypy/dist/pypy/interpreter/stablecompiler/transformer.py	Sat Oct 15 17:51:21 2005
@@ -734,8 +734,8 @@
 
     def atom_lsqb(self, nodelist):
         if nodelist[1][0] == token.RSQB:
-            return List([])
-        return self.com_list_constructor(nodelist[1])
+            return List([], lineno=nodelist[0][2])
+        return self.com_list_constructor(nodelist[1], nodelist[0][2])
 
     def atom_lbrace(self, nodelist):
         if nodelist[1][0] == token.RBRACE:
@@ -1097,7 +1097,7 @@
             stmts.append(result)
 
     if hasattr(symbol, 'list_for'):
-        def com_list_constructor(self, nodelist):
+        def com_list_constructor(self, nodelist, lineno):
             # listmaker: test ( list_for | (',' test)* [','] )
             values = []
             for i in range(1, len(nodelist)):
@@ -1108,7 +1108,7 @@
                 elif nodelist[i][0] == token.COMMA:
                     continue
                 values.append(self.com_node(nodelist[i]))
-            return List(values, lineno=values[0].lineno)
+            return List(values, lineno=lineno)
 
         def com_list_comprehension(self, expr, node):
             # list_iter: list_for | list_if
@@ -1149,11 +1149,11 @@
             assert node[0] == symbol.list_iter
             return node[1]
     else:
-        def com_list_constructor(self, nodelist):
+        def com_list_constructor(self, nodelist, lineno):
             values = []
             for i in range(1, len(nodelist), 2):
                 values.append(self.com_node(nodelist[i]))
-            return List(values)
+            return List(values, lineno)
 
     if hasattr(symbol, 'gen_for'):
         def com_generator_expression(self, expr, node):



More information about the Pypy-commit mailing list