[Python-checkins] CVS: python/dist/src/Tools/compiler/compiler pycodegen.py,1.53,1.54 syntax.py,1.1,1.2 transformer.py,1.26,1.27

Jeremy Hylton jhylton@users.sourceforge.net
Mon, 17 Sep 2001 12:33:50 -0700


Update of /cvsroot/python/python/dist/src/Tools/compiler/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv24554

Modified Files:
	pycodegen.py syntax.py transformer.py 
Log Message:
Last set of change to get regression tests to pass

Remove the only test in the syntax module.  It ends up that the
transformer must handle this error case.

In the transformer, check for a list compression in com_assign_list()
by looking for a list_for node where a comma is expected.

In pycodegen.compile() re-raise the SyntaxError rather than catching
it and exiting





Index: pycodegen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/pycodegen.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** pycodegen.py	2001/09/17 18:03:55	1.53
--- pycodegen.py	2001/09/17 19:33:48	1.54
***************
*** 50,54 ****
          mod.compile(display)
      except SyntaxError, err:
!         print "SyntaxError:", err
      else:
          f = open(filename + "c", "wb")
--- 50,54 ----
          mod.compile(display)
      except SyntaxError, err:
!         raise
      else:
          f = open(filename + "c", "wb")

Index: syntax.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/syntax.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** syntax.py	2001/09/17 18:03:55	1.1
--- syntax.py	2001/09/17 19:33:48	1.2
***************
*** 40,45 ****
          # the transformer module handles many of these
          for target in node.nodes:
!             if isinstance(target, ast.AssList):
!                 if target.lineno is None:
!                     target.lineno = node.lineno
!                 self.error(target, "can't assign to list comprehension")
--- 40,46 ----
          # the transformer module handles many of these
          for target in node.nodes:
!             pass
! ##            if isinstance(target, ast.AssList):
! ##                if target.lineno is None:
! ##                    target.lineno = node.lineno
! ##                self.error(target, "can't assign to list comprehension")

Index: transformer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/transformer.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** transformer.py	2001/08/29 20:56:30	1.26
--- transformer.py	2001/09/17 19:33:48	1.27
***************
*** 944,947 ****
--- 944,951 ----
          assigns = []
          for i in range(1, len(node), 2):
+             if i + 1 < len(node):
+                 if node[i + 1][0] == symbol.list_for:
+                     raise SyntaxError, "can't assign to list comprehension"
+                 assert node[i + 1][0] == token.COMMA, node[i + 1]
              assigns.append(self.com_assign(node[i], assigning))
          return AssList(assigns)