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
commita243a6a2b34eb9ef5cba3346796160e06ba77930 (patch)
treee9c0f8a9dab30b5f15ebaa408a90ed523b4a9f18 /coverage/tracer.c
parentc826639c8ba8e9076ace7d030dc5a9f6f899c9ee (diff)
downloadpython-coveragepy-git-a243a6a2b34eb9ef5cba3346796160e06ba77930.tar.gz
C trace function now roundtrips properly. Fixes #123 and #125.
--HG-- branch : bug_123
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 2faabb62..1017c9d4 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().
*