Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r47834:d71f4eb207d1
Date: 2011-10-05 22:00 +0200
http://bitbucket.org/pypy/pypy/changeset/d71f4eb207d1/
Log: Implement sys.gettrace()
diff --git a/pypy/interpreter/executioncontext.py
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -175,6 +175,9 @@
self.w_tracefunc = w_func
self.space.frame_trace_action.fire()
+ def gettrace(self):
+ return self.w_tracefunc
+
def setprofile(self, w_func):
"""Set the global trace function."""
if self.space.is_w(w_func, self.space.w_None):
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -55,6 +55,7 @@
'exc_info' : 'vm.exc_info',
'exc_clear' : 'vm.exc_clear',
'settrace' : 'vm.settrace',
+ 'gettrace' : 'vm.gettrace',
'setprofile' : 'vm.setprofile',
'getprofile' : 'vm.getprofile',
'call_tracing' : 'vm.call_tracing',
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
@@ -478,6 +478,7 @@
sys.settrace(trace)
try:
x()
+ assert sys.gettrace() is trace
finally:
sys.settrace(None)
assert len(counts) == 1
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -129,6 +129,11 @@
function call. See the debugger chapter in the library manual."""
space.getexecutioncontext().settrace(w_func)
+def gettrace(space):
+ """Return the global debug tracing function set with sys.settrace.
+See the debugger chapter in the library manual."""
+ return space.getexecutioncontext().gettrace()
+
def setprofile(space, w_func):
"""Set the profiling function. It will be called on each function call
and return. See the profiler chapter in the library manual."""
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit