[pypy-commit] pypy default: port the cpython test and improve situation a little bit
fijal
noreply at buildbot.pypy.org
Tue May 5 10:49:43 CEST 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r77141:8f9262dc29ee
Date: 2015-05-05 10:49 +0200
http://bitbucket.org/pypy/pypy/changeset/8f9262dc29ee/
Log: port the cpython test and improve situation a little bit
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -34,6 +34,9 @@
is_being_profiled = False
w_locals = None
+ def __init__(self, pycode):
+ self.f_lineno = pycode.co_firstlineno
+
class PyFrame(W_Root):
"""Represents a frame for a regular Python function
that needs to be interpreted.
@@ -105,7 +108,7 @@
def getorcreatedebug(self):
if self.debugdata is None:
- self.debugdata = FrameDebugData()
+ self.debugdata = FrameDebugData(self.pycode)
return self.debugdata
def get_w_f_trace(self):
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -607,6 +607,41 @@
# be changed.
assert sys.float_repr_style == "short"
+class AppTestSysSettracePortedFromCpython(object):
+ def test_sys_settrace(self):
+ import sys
+
+ class Tracer:
+ def __init__(self):
+ self.events = []
+ def trace(self, frame, event, arg):
+ self.events.append((frame.f_lineno, event))
+ return self.trace
+ def traceWithGenexp(self, frame, event, arg):
+ (o for o in [1])
+ self.events.append((frame.f_lineno, event))
+ return self.trace
+
+ def compare_events(line_offset, events, expected_events):
+ events = [(l - line_offset, e) for (l, e) in events]
+ assert events == expected_events
+
+ def run_test2(func):
+ tracer = Tracer()
+ func(tracer.trace)
+ sys.settrace(None)
+ compare_events(func.func_code.co_firstlineno,
+ tracer.events, func.events)
+
+
+ def _settrace_and_return(tracefunc):
+ sys.settrace(tracefunc)
+ sys._getframe().f_back.f_trace = tracefunc
+ def settrace_and_return(tracefunc):
+ _settrace_and_return(tracefunc)
+ settrace_and_return.events = [(1, 'return')]
+ run_test2(settrace_and_return)
+
class AppTestCurrentFrames:
def test_current_frames(self):
More information about the pypy-commit
mailing list