[pypy-svn] r73685 - in pypy/branch/decouple-host-opcodes/pypy: interpreter objspace/flow tool/pytest

fijal at codespeak.net fijal at codespeak.net
Mon Apr 12 23:28:03 CEST 2010


Author: fijal
Date: Mon Apr 12 23:28:01 2010
New Revision: 73685

Modified:
   pypy/branch/decouple-host-opcodes/pypy/interpreter/baseobjspace.py
   pypy/branch/decouple-host-opcodes/pypy/objspace/flow/objspace.py
   pypy/branch/decouple-host-opcodes/pypy/tool/pytest/appsupport.py
Log:
Disallow space.eval(cpycode) and space.exec_(cpycode) alltogether.
Move createframe logic to choose based on magic to flow objspace
(tentatively, it should be killed alltogether)


Modified: pypy/branch/decouple-host-opcodes/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/decouple-host-opcodes/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/decouple-host-opcodes/pypy/interpreter/baseobjspace.py	Mon Apr 12 23:28:01 2010
@@ -594,14 +594,7 @@
 
     def createframe(self, code, w_globals, closure=None):
         "Create an empty PyFrame suitable for this code object."
-        from pypy.interpreter.pycode import PyCode
-        assert isinstance(code, PyCode)
-        magic = code.magic
-        if magic == self.host_magic:
-            return self.HostFrameClass(self, code, w_globals, closure)
-        elif magic == self.our_magic:
-            return self.FrameClass(self, code, w_globals, closure)
-        raise ValueError("bad magic %s" % magic)
+        return self.FrameClass(self, code, w_globals, closure)
 
     def allocate_lock(self):
         """Return an interp-level Lock object if threads are enabled,
@@ -940,10 +933,11 @@
         import types
         from pypy.interpreter.pycode import PyCode
         if isinstance(expression, str):
-            expression = compile(expression, '?', 'eval')
+            compiler = self.createcompiler()
+            expression = compiler.compile(expression, '?', 'eval', 0,
+                                         hidden_applevel=hidden_applevel)
         if isinstance(expression, types.CodeType):
-            expression = PyCode._from_code(self, expression,
-                                          hidden_applevel=hidden_applevel)
+            raise Exception("space.eval(cpycode) Should not be used")
         if not isinstance(expression, PyCode):
             raise TypeError, 'space.eval(): expected a string, code or PyCode object'
         return expression.exec_code(self, w_globals, w_locals)
@@ -960,8 +954,7 @@
             statement = compiler.compile(statement, filename, 'exec', 0,
                                          hidden_applevel=hidden_applevel)
         if isinstance(statement, types.CodeType):
-            statement = PyCode._from_code(self, statement,
-                                          hidden_applevel=hidden_applevel)
+            raise Exception("space.eval(cpycode) Should not be used")
         if not isinstance(statement, PyCode):
             raise TypeError, 'space.exec_(): expected a string, code or PyCode object'
         w_key = self.wrap('__builtins__')

Modified: pypy/branch/decouple-host-opcodes/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/decouple-host-opcodes/pypy/objspace/flow/objspace.py	(original)
+++ pypy/branch/decouple-host-opcodes/pypy/objspace/flow/objspace.py	Mon Apr 12 23:28:01 2010
@@ -85,6 +85,14 @@
             return Constant({})
         return self.do_operation('newdict')
 
+    def createframe(self, code, w_globals, closure=None):
+        magic = code.magic
+        if magic == self.host_magic:
+            return self.HostFrameClass(self, code, w_globals, closure)
+        elif magic == self.our_magic:
+            return self.FrameClass(self, code, w_globals, closure)
+        raise ValueError("bad magic %s" % magic)
+
     def newtuple(self, args_w):
         try:
             content = [self.unwrap(w_arg) for w_arg in args_w]

Modified: pypy/branch/decouple-host-opcodes/pypy/tool/pytest/appsupport.py
==============================================================================
--- pypy/branch/decouple-host-opcodes/pypy/tool/pytest/appsupport.py	(original)
+++ pypy/branch/decouple-host-opcodes/pypy/tool/pytest/appsupport.py	Mon Apr 12 23:28:01 2010
@@ -218,7 +218,8 @@
         for key, w_value in kwds_w.items():
             space.setitem(w_locals, space.wrap(key), w_value)
         try:
-            space.exec_(source.compile(), frame.w_globals, w_locals)
+            space.exec_(str(source), frame.w_globals, w_locals,
+                        filename=__file__)
         except OperationError, e:
             if e.match(space, w_ExpectedException):
                 return _exc_info(space, e)



More information about the Pypy-commit mailing list