From d790754b0905b17f34a77aa8e3b05e52561c15e1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 27 Apr 2010 22:00:59 -0400 Subject: Properly record multiple exits separately. Fixes #62. --- coverage/tracer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'coverage/tracer.c') diff --git a/coverage/tracer.c b/coverage/tracer.c index 448f945..1d22729 100644 --- a/coverage/tracer.c +++ b/coverage/tracer.c @@ -97,6 +97,7 @@ typedef struct { /* The parent frame for the last exception event, to fix missing returns. */ PyFrameObject * last_exc_back; + int last_exc_firstlineno; #if COLLECT_STATS struct { @@ -280,7 +281,7 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg) STATS( self->stats.missed_returns++; ) if (self->depth >= 0) { if (self->tracing_arcs && self->cur_file_data) { - if (Tracer_record_pair(self, self->last_line, -1) < 0) { + if (Tracer_record_pair(self, self->last_line, -self->last_exc_firstlineno) < 0) { return RET_ERROR; } } @@ -376,7 +377,8 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg) /* A near-copy of this code is above in the missing-return handler. */ if (self->depth >= 0) { if (self->tracing_arcs && self->cur_file_data) { - if (Tracer_record_pair(self, self->last_line, -1) < 0) { + int first = frame->f_code->co_firstlineno; + if (Tracer_record_pair(self, self->last_line, -first) < 0) { return RET_ERROR; } } @@ -436,6 +438,7 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg) */ STATS( self->stats.exceptions++; ) self->last_exc_back = frame->f_back; + self->last_exc_firstlineno = frame->f_code->co_firstlineno; break; default: -- cgit v1.2.1