[pypy-svn] r60053 - in pypy/trunk/pypy/interpreter: pyparser test

fijal at codespeak.net fijal at codespeak.net
Fri Nov 21 14:35:20 CET 2008


Author: fijal
Date: Fri Nov 21 14:35:17 2008
New Revision: 60053

Modified:
   pypy/trunk/pypy/interpreter/pyparser/asthelper.py
   pypy/trunk/pypy/interpreter/test/test_compiler.py
Log:
Raise syntax error in this case. CPython does that as well (otherwise we
end up in inconsistent stack)


Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/asthelper.py	(original)
+++ pypy/trunk/pypy/interpreter/pyparser/asthelper.py	Fri Nov 21 14:35:17 2008
@@ -94,6 +94,9 @@
             dstararg_token = tokens[index]
             break
         elif cur_token.get_value() == 'for':
+            if building_kw:
+                raise SyntaxError("invalid syntax", cur_token.lineno,
+                                  cur_token.col)
             if len(arguments) != 1:
                 raise SyntaxError("invalid syntax", cur_token.lineno,
                                   cur_token.col)

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 14:35:17 2008
@@ -683,6 +683,16 @@
         else:
             py.test.fail("Did not raise")
 
+    def test_invalid_genexp(self):
+        code = 'dict(a = i for i in xrange(10))'
+        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):
         self.space.config.objspace.pyversion = "2.4"



More information about the Pypy-commit mailing list