summaryrefslogtreecommitdiff
path: root/coverage/tracer.c
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:42:41 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:42:41 -0400
commit6c4465b4b6b56dcae5c658b1dee9376441876d5a (patch)
tree0e4bc1351d73693900ecc2becd006a466eda21ec /coverage/tracer.c
parentc10bf85ee341d0378b73e729a2bd048d079ca6f2 (diff)
downloadpython-coveragepy-6c4465b4b6b56dcae5c658b1dee9376441876d5a.tar.gz
C trace function now roundtrips properly. Fixes #123 and #125.
Diffstat (limited to 'coverage/tracer.c')
-rw-r--r--coverage/tracer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/coverage/tracer.c b/coverage/tracer.c
index 2faabb6..1017c9d 100644
--- a/coverage/tracer.c
+++ b/coverage/tracer.c
@@ -365,6 +365,9 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg_unused)
}
}
self->cur_file_data = file_data;
+ /* Make the frame right in case settrace(gettrace()) happens. */
+ Py_INCREF(self);
+ frame->f_trace = (PyObject*)self;
SHOWLOG(self->depth, frame->f_lineno, filename, "traced");
}
else {
@@ -497,12 +500,12 @@ done:
}
/*
- * Python has two ways to set the trace function: sys.settrace(fn), which
+ * Python has two ways to set the trace function: sys.settrace(fn), which
* takes a Python callable, and PyEval_SetTrace(func, obj), which takes
* a C function and a Python object. The way these work together is that
* sys.settrace(pyfn) calls PyEval_SetTrace(builtin_func, pyfn), using the
* Python callable as the object in PyEval_SetTrace. So sys.gettrace()
- * simply returns the Python object used as the second argument to
+ * simply returns the Python object used as the second argument to
* PyEval_SetTrace. So sys.gettrace() will return our self parameter, which
* means it must be callable to be used in sys.settrace().
*