[pypy-svn] r58047 - in pypy/branch/tuple-nonresizable-395/pypy/interpreter: astcompiler pyparser
fijal at codespeak.net
fijal at codespeak.net
Wed Sep 10 19:23:43 CEST 2008
Author: fijal
Date: Wed Sep 10 19:23:42 2008
New Revision: 58047
Modified:
pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/opt.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyparser/astbuilder.py
Log:
Make annotator happier. This also means that we copy stuff without any good
reason. To fix this we would probably need to rewrite pyparser and astcompier
a fair bit :(
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/opt.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/opt.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/opt.py Wed Sep 10 19:23:42 2008
@@ -234,7 +234,9 @@
for subnode in node.nodes:
if not isinstance(subnode, ast.Const):
return node # not all constants
- consts_w = [subnode.value for subnode in node.nodes]
+ # this isinstance is only to make annotator happier
+ consts_w = [subnode.value for subnode in node.nodes
+ if isinstance(subnode, ast.Const)]
return ast.Const(self.space.newtuple(consts_w))
def visitFor(self, node):
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyparser/astbuilder.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyparser/astbuilder.py Wed Sep 10 19:23:42 2008
@@ -416,9 +416,9 @@
if l == 1:
builder.push(atoms[0])
return
- items = []
token = atoms[1]
if isinstance(token, TokenObject) and token.name == builder.parser.tokens['COMMA']:
+ items = []
for i in range(0, l, 2): # this is atoms not 1
items.append(atoms[i])
else:
@@ -433,7 +433,8 @@
if not isinstance(item, ast.Const):
builder.push(ast.Tuple(items, lineno))
return
- values = [item.value for item in items]
+ # isinstance as a hint for annotator
+ values = [item.value for item in items if isinstance(item, ast.Const)]
builder.push(ast.Const(builder.space.newtuple(values), lineno))
return
@@ -740,9 +741,10 @@
isConst = False
break
if not isConst:
- builder.push(ast.Tuple(items, atoms[0].lineno))
+ builder.push(ast.Tuple([i for i in items if isinstance(i, ast.Node)], atoms[0].lineno))
else:
- builder.push(ast.Const(builder.space.newtuple(items), atoms[0].lineno))
+ builder.push(ast.Const(builder.space.newtuple(
+ [i for i in items if isinstance(i, ast.Const)]), atoms[0].lineno))
def build_while_stmt(builder, nb):
"""while_stmt: 'while' test ':' suite ['else' ':' suite]"""
More information about the Pypy-commit
mailing list