[pypy-svn] r59928 - in pypy/trunk/pypy/interpreter: astcompiler test
fijal at codespeak.net
fijal at codespeak.net
Sat Nov 15 12:49:08 CET 2008
Author: fijal
Date: Sat Nov 15 12:49:05 2008
New Revision: 59928
Modified:
pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
pypy/trunk/pypy/interpreter/test/test_compiler.py
Log:
Don't allow assignments to empty sequences and an awkward test for it
(which includes with statement). Maybe another test with normal assignment?
Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original)
+++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Sat Nov 15 12:49:05 2008
@@ -976,6 +976,8 @@
assert False, "visitAssAttr unexpected flags: %d" % node.flags
def _visitAssSequence(self, node, op='UNPACK_SEQUENCE'):
+ if not node.nodes:
+ raise SyntaxError('Cannot assign to empty sequence')
if findOp(node) != OP_DELETE:
self.emitop_int(op, len(node.nodes))
for child in node.nodes:
Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_compiler.py Sat Nov 15 12:49:05 2008
@@ -654,6 +654,21 @@
assert isinstance(code, PyCode)
assert code.co_filename == '<filename2>'
+ def test_with_empty_tuple(self):
+ source = py.code.Source("""
+ from __future__ import with_statement
+
+ with x as ():
+ pass
+ """)
+ try:
+ self.compiler.compile(str(source), '<filename>', 'exec', 0)
+ except OperationError, e:
+ if not e.match(self.space, self.space.w_SyntaxError):
+ raise
+ else:
+ py.test.fail("Did not raise")
+
def test_yield_in_finally(self): # behavior changed in 2.5
code ='def f():\n try:\n yield 19\n finally:\n pass\n'
self.compiler.compile(code, '', 'single', 0)
More information about the Pypy-commit
mailing list