[pypy-svn] r17533 - in pypy/dist/pypy/interpreter: astcompiler test
ac at codespeak.net
ac at codespeak.net
Tue Sep 13 18:24:18 CEST 2005
Author: ac
Date: Tue Sep 13 18:24:14 2005
New Revision: 17533
Modified:
pypy/dist/pypy/interpreter/astcompiler/pycodegen.py
pypy/dist/pypy/interpreter/test/test_compiler.py
Log:
Reject import * in nested functions.
Modified: pypy/dist/pypy/interpreter/astcompiler/pycodegen.py
==============================================================================
--- pypy/dist/pypy/interpreter/astcompiler/pycodegen.py (original)
+++ pypy/dist/pypy/interpreter/astcompiler/pycodegen.py Tue Sep 13 18:24:14 2005
@@ -825,6 +825,8 @@
self.emitop('IMPORT_NAME', node.modname)
for name, alias in node.names:
if name == '*':
+ if self.scope.nested:
+ raise SyntaxError('import * is not allowed in a nested function')
self.namespace = 0
self.emit('IMPORT_STAR')
# There can only be one name w/ from ... import *
Modified: pypy/dist/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/dist/pypy/interpreter/test/test_compiler.py Tue Sep 13 18:24:14 2005
@@ -108,6 +108,16 @@
ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
+ def test_scope_exec_with_nested_free(self):
+ e = py.test.raises(OperationError, self.compiler.compile, """if 1:
+ def unoptimized_clash1(x):
+ exec "z=3"
+ def f():
+ return x
+ return f""", '', 'exec', 0)
+ ex = e.value
+ assert ex.match(self.space, self.space.w_SyntaxError)
+
def test_scope_importstar_in_nested(self):
e = py.test.raises(OperationError, self.compiler.compile, """if 1:
def unoptimized_clash1(x):
@@ -187,16 +197,10 @@
def setup_method(self, method):
self.compiler = PythonAstCompiler(self.space)
- def test_scope_unoptimized_clash1(self):
- py.test.skip("INPROGESS")
-
- def test_scope_unoptimized_clash1_b(self):
- py.test.skip("INPROGESS")
-
- def test_scope_importstar_in_nested(self):
+ def test_scope_importstar_with_nested_free(self):
py.test.skip("INPROGESS")
- def test_scope_importstar_with_nested_free(self):
+ def test_scope_exec_with_nested_free(self):
py.test.skip("INPROGESS")
class SkippedForNowTestPyPyCompiler(BaseTestCompiler):
More information about the Pypy-commit
mailing list