summaryrefslogtreecommitdiff
path: root/coverage/tracer.c
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-10-11 20:28:08 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-10-11 20:28:08 -0400
commit6ceadfa9b8add3299aea41fb3f43af2f2f2d72d9 (patch)
tree0ecf2e13bc04de1556a504a01392eae3aa7536bf /coverage/tracer.c
parentd93e5d5da230876e946aa94f59e706d3b798c62b (diff)
downloadpython-coveragepy-git-6ceadfa9b8add3299aea41fb3f43af2f2f2d72d9.tar.gz
Properly initialize the arc bookkeeping.
Diffstat (limited to 'coverage/tracer.c')
-rw-r--r--coverage/tracer.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/coverage/tracer.c b/coverage/tracer.c
index 428df4d3..c5c1eaf9 100644
--- a/coverage/tracer.c
+++ b/coverage/tracer.c
@@ -38,11 +38,17 @@
typedef struct {
PyObject_HEAD
+ /* Python objects manipulated directly by the Collector class. */
PyObject * should_trace;
PyObject * data;
PyObject * should_trace_cache;
PyObject * arcs;
+
+ /* Has the tracer been started? */
int started;
+ /* Are we tracing arcs, or just lines? */
+ int tracing_arcs;
+
/* The index of the last-used entry in data_stack. */
int depth;
/* Filenames to record at each level, or NULL if not recording. */
@@ -61,13 +67,18 @@ Tracer_init(Tracer *self, PyObject *args, PyObject *kwds)
self->should_trace = NULL;
self->data = NULL;
self->should_trace_cache = NULL;
+ self->arcs = NULL;
+
self->started = 0;
+ self->tracing_arcs = 0;
+
self->depth = -1;
self->data_stack = PyMem_Malloc(STACK_DELTA*sizeof(PyObject *));
if (self->data_stack == NULL) {
return -1;
}
self->data_stack_alloc = STACK_DELTA;
+
self->last_exc_back = NULL;
return 0;
}
@@ -253,7 +264,7 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
Python itself fixed this problem in 2.4. Pyexpat still has the bug.
I've reported the problem with pyexpat as http://bugs.python.org/issue6359 .
- If it gets fixed, this code should still work properly. Maybe someday
+ If it gets fixed, this code should still work properly. Maybe some day
the bug will be fixed everywhere coverage.py is supported, and we can
remove this missing-return detection.
@@ -271,6 +282,7 @@ Tracer_start(Tracer *self, PyObject *args)
{
PyEval_SetTrace((Py_tracefunc)Tracer_trace, (PyObject*)self);
self->started = 1;
+ self->tracing_arcs = self->arcs && PyObject_IsTrue(self->arcs);
return Py_BuildValue("");
}