[pypy-commit] pypy default: fix translation
fijal
noreply at buildbot.pypy.org
Wed Nov 18 11:16:59 EST 2015
Author: fijal
Branch:
Changeset: r80760:1f06b485fd84
Date: 2015-11-18 18:17 +0200
http://bitbucket.org/pypy/pypy/changeset/1f06b485fd84/
Log: fix translation
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -391,8 +391,7 @@
self.check_signal_action = None # changed by the signal module
self.user_del_action = UserDelAction(self)
self._code_of_sys_exc_info = None
- self._code_hook = None
-
+
# can be overridden to a subclass
self.initialize()
@@ -1242,13 +1241,6 @@
self.setitem(w_globals, w_key, self.wrap(self.builtin))
return statement.exec_code(self, w_globals, w_locals)
- def new_code_hook(self, w_code):
- if self._code_hook is not None:
- try:
- self.call_function(self._code_hook, w_code)
- except OperationError, e:
- e.write_unraisable(self, "new_code_hook()")
-
def appexec(self, posargs_w, source):
""" return value from executing given source at applevel.
EXPERIMENTAL. The source must look like
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -50,6 +50,9 @@
kwargname = varnames[argcount] if code.co_flags & CO_VARKEYWORDS else None
return Signature(argnames, varargname, kwargname)
+class CodeHookCache(object):
+ def __init__(self, space):
+ self._code_hook = None
class PyCode(eval.Code):
"CPython-style code objects."
@@ -86,7 +89,15 @@
self._signature = cpython_code_signature(self)
self._initialize()
self._init_ready()
- self.space.new_code_hook(self)
+ self.new_code_hook()
+
+ def new_code_hook(self):
+ code_hook = self.space.fromcache(CodeHookCache)._code_hook
+ if code_hook is not None:
+ try:
+ self.space.call_function(code_hook, self)
+ except OperationError, e:
+ e.write_unraisable(self.space, "new_code_hook()")
def _initialize(self):
if self.co_cellvars:
diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -1,5 +1,6 @@
from pypy.interpreter.error import OperationError, wrap_oserror
from pypy.interpreter.gateway import unwrap_spec
+from pypy.interpreter.pycode import CodeHookCache
from pypy.interpreter.pyframe import PyFrame
from pypy.interpreter.mixedmodule import MixedModule
from rpython.rlib.objectmodel import we_are_translated
@@ -153,7 +154,8 @@
return specialized_zip_2_lists(space, w_list1, w_list2)
def set_code_callback(space, w_callable):
+ cache = space.fromcache(CodeHookCache)
if space.is_none(w_callable):
- space._code_hook = None
+ cache._code_hook = None
else:
- space._code_hook = w_callable
\ No newline at end of file
+ cache._code_hook = w_callable
\ No newline at end of file
More information about the pypy-commit
mailing list