[pypy-svn] r60052 - in pypy/trunk/pypy/interpreter: astcompiler test

fijal at codespeak.net fijal at codespeak.net
Fri Nov 21 13:08:48 CET 2008


Author: fijal
Date: Fri Nov 21 13:08:47 2008
New Revision: 60052

Modified:
   pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
   pypy/trunk/pypy/interpreter/test/test_compiler.py
Log:
A test and a fix for one InternalCompilerError


Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py	(original)
+++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py	Fri Nov 21 13:08:47 2008
@@ -1533,6 +1533,8 @@
     def visitSubscript(self, node):
         self.main._visitSubscript(node, True)
 
+    def visitYield(self, node):
+        raise SyntaxError("augmented assignment to yield expression not possible")
 
 class AugStoreVisitor(ast.ASTVisitor):
     def __init__(self, main_visitor):

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	Fri Nov 21 13:08:47 2008
@@ -673,6 +673,15 @@
         code ='def f():\n try:\n  yield 19\n finally:\n  pass\n'
         self.compiler.compile(code, '', 'single', 0)
 
+    def test_assign_to_yield(self):
+        code = 'def f(): (yield bar) += y'
+        try:
+            self.compiler.compile(code, '', 'single', 0)
+        except OperationError, e:
+            if not e.match(self.space, self.space.w_SyntaxError):
+                raise
+        else:
+            py.test.fail("Did not raise")
 
 class TestECCompiler(BaseTestCompiler):
     def setup_method(self, method):



More information about the Pypy-commit mailing list