[pypy-svn] r17219 - pypy/dist/pypy/interpreter/pyparser

adim at codespeak.net adim at codespeak.net
Mon Sep 5 11:36:30 CEST 2005


Author: adim
Date: Mon Sep  5 11:36:29 2005
New Revision: 17219

Modified:
   pypy/dist/pypy/interpreter/pyparser/astbuilder.py
Log:
small annotation fixes


Modified: pypy/dist/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/astbuilder.py	(original)
+++ pypy/dist/pypy/interpreter/pyparser/astbuilder.py	Mon Sep  5 11:36:29 2005
@@ -529,7 +529,9 @@
     left = atoms[0]
     for i in range(2,l,2):
         right = atoms[i]
-        op = atoms[i-1].name
+        op_node = atoms[i-1]
+        assert isinstance(op_node, TokenObject)
+        op = op_node.name
         if op == tok.STAR:
             left = ast.Mul( [ left, right ] )
         elif op == tok.SLASH:
@@ -749,7 +751,7 @@
         builder.push(atoms[0])
         return
     items = []
-    if atoms[1].name == tok.COMMA:
+    if isinstance(atoms[1], TokenObject) and atoms[1].name == tok.COMMA:
         for i in range(0, l, 2): # this is atoms not 1
             items.append(atoms[i])
     else:
@@ -775,13 +777,13 @@
     """
     atoms = get_atoms(builder, nb)
     # Case 1 : '(' ...
-    if atoms[0].name == tok.LPAR:
+    if isinstance(atoms[0], TokenObject) and atoms[0].name == tok.LPAR:
         if len(atoms) == 2: # and atoms[1].token == tok.RPAR:
             builder.push(ArglistObject([], None, None))
         elif len(atoms) == 3: # '(' Arglist ')'
             # push arglist on the stack
             builder.push(atoms[1])
-    elif atoms[0].name == tok.LSQB:
+    elif isinstance(atoms[0], TokenObject) and atoms[0].name == tok.LSQB:
         if isinstance(atoms[1], SlicelistObject):
             builder.push(atoms[1])
         else:



More information about the Pypy-commit mailing list