[pypy-svn] r66467 - in pypy/branch/parser-compiler/pypy: interpreter module/__builtin__/test

benjamin at codespeak.net benjamin at codespeak.net
Tue Jul 21 04:25:23 CEST 2009


Author: benjamin
Date: Tue Jul 21 04:25:22 2009
New Revision: 66467

Modified:
   pypy/branch/parser-compiler/pypy/interpreter/pycompiler.py
   pypy/branch/parser-compiler/pypy/module/__builtin__/test/test_builtin.py
Log:
reject invalid flags to compile()

Modified: pypy/branch/parser-compiler/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/pycompiler.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/pycompiler.py	Tue Jul 21 04:25:22 2009
@@ -231,8 +231,15 @@
         from pypy.interpreter.pyparser.pythonlexer import TokenIndentationError
         from pypy.interpreter.astcompiler.astbuilder import ast_from_node
         from pypy.interpreter.astcompiler.codegen import compile_ast
+        from pypy.interpreter.astcompiler import consts
 
         space = self.space
+
+        if flags & ~(consts.PyCF_SOURCE_IS_UTF8 | consts.PyCF_DONT_IMPLY_DEDENT
+                     | self.futureFlags.allowed_flags):
+            raise OperationError(space.w_ValueError,
+                                 space.wrap("invalid compile flags"))
+
         space.timer.start("PythonAST compile")
         try:
             flags |= getFutures(self.futureFlags, source)

Modified: pypy/branch/parser-compiler/pypy/module/__builtin__/test/test_builtin.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/module/__builtin__/test/test_builtin.py	(original)
+++ pypy/branch/parser-compiler/pypy/module/__builtin__/test/test_builtin.py	Tue Jul 21 04:25:22 2009
@@ -400,6 +400,7 @@
         raises(SyntaxError, compile, '-', '?', 'eval')
         raises(ValueError, compile, '"\\xt"', '?', 'eval')
         raises(ValueError, compile, '1+2', '?', 'maybenot')
+        raises(ValueError, compile, "\n", "<string>", "exec", 0xff)
         raises(TypeError, compile, '1+2', 12, 34)
 
     def test_unicode_compile(self):



More information about the Pypy-commit mailing list