[pypy-commit] pypy default: Change the return value from None to the not_from_assembler object
arigo
noreply at buildbot.pypy.org
Wed Oct 8 21:12:48 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r73846:d1da93ec991a
Date: 2014-10-08 21:12 +0200
http://bitbucket.org/pypy/pypy/changeset/d1da93ec991a/
Log: Change the return value from None to the not_from_assembler object
itself, to make it directly useful for sys.settrace().
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -155,10 +155,11 @@
self.w_callable = w_callable
def descr_call(self, __args__):
_call_not_in_trace(self.space, self.w_callable, __args__)
+ return self
@jit.not_in_trace
def _call_not_in_trace(space, w_callable, __args__):
- # this must return None
+ # this _call_not_in_trace() must return None
space.call_args(w_callable, __args__)
def not_from_assembler_new(space, w_subtype, w_callable):
@@ -170,8 +171,14 @@
callable, but not from the JIT-produced assembler. It is called
from the interpreted mode, and from the JIT creation (pyjitpl) or
exiting (blackhole) steps, but just not from the final assembler.
-The callable should return None! (Its actual return value is
-ignored.)
+
+Note that the return value of the callable is ignored, because
+there is no reasonable way to guess what it sound be in case the
+function is not called.
+
+This is meant to be used notably in sys.settrace() for coverage-
+like tools. For that purpose, if g = not_from_assembler(f), then
+'g(*args)' may call 'f(*args)' but it always return g itself.
""",
__new__ = interp2app(not_from_assembler_new),
__call__ = interp2app(W_NotFromAssembler.descr_call),
diff --git a/pypy/module/pypyjit/test/test_jit_not_in_trace.py b/pypy/module/pypyjit/test/test_jit_not_in_trace.py
--- a/pypy/module/pypyjit/test/test_jit_not_in_trace.py
+++ b/pypy/module/pypyjit/test/test_jit_not_in_trace.py
@@ -8,7 +8,7 @@
def f(x, y):
return 42
r = f(3, 4)
- assert r is None
+ assert r is f
def test_not_from_assembler_exception(self):
import pypyjit
More information about the pypy-commit
mailing list