[pypy-svn] r66245 - in pypy/branch/parser-compiler/pypy/interpreter/astcompiler: . test
benjamin at codespeak.net
benjamin at codespeak.net
Wed Jul 15 20:31:49 CEST 2009
Author: benjamin
Date: Wed Jul 15 20:31:48 2009
New Revision: 66245
Modified:
pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py
pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_symtable.py
Log:
add a temporary name for the with statement
Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py (original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py Wed Jul 15 20:31:48 2009
@@ -402,6 +402,10 @@
self.new_temporary_name()
ast.GenericASTVisitor.visit_ListComp(self, lc)
+ def visit_With(self, wih):
+ self.new_temporary_name()
+ ast.GenericASTVisitor.visit_With(self, wih)
+
def visit_arguments(self, arguments):
assert isinstance(self.scope, FunctionScope) # Annotator hint.
if arguments.args:
Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_symtable.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_symtable.py (original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_symtable.py Wed Jul 15 20:31:48 2009
@@ -308,6 +308,12 @@
exc = py.test.raises(SyntaxError, self.func_scope, input).value
assert exc.msg == "return outside function"
- def test_listcomp_tmpname(self):
+ def test_tmpnames(self):
scp = self.mod_scope("[x for x in y]")
assert scp.lookup("_[0]") == symtable.SCOPE_LOCAL
+ scp = self.mod_scope("with x: pass")
+ assert scp.lookup("_[0]") == symtable.SCOPE_LOCAL
+ # Just in case.
+ scp = self.mod_scope("with [x for y in z]: pass")
+ assert scp.lookup("_[0]") == symtable.SCOPE_LOCAL
+ assert scp.lookup("_[1]") == symtable.SCOPE_LOCAL
More information about the Pypy-commit
mailing list