diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-15 22:51:42 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-15 22:51:42 -0400 |
commit | acb2e8e79230e9a6967fd82e95ec2fde8a293b08 (patch) | |
tree | c52d8173554beb67f960a1ff4e205b198dc41692 /coverage/tracer.c | |
parent | 44527cc9db62aa3979c69abe4edb7070aafd6897 (diff) | |
download | python-coveragepy-git-acb2e8e79230e9a6967fd82e95ec2fde8a293b08.tar.gz |
should_trace now returns a FileDisposition object
--HG--
branch : django
Diffstat (limited to 'coverage/tracer.c')
-rw-r--r-- | coverage/tracer.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/coverage/tracer.c b/coverage/tracer.c index 97dd113b..ca8d61c1 100644 --- a/coverage/tracer.c +++ b/coverage/tracer.c @@ -259,6 +259,7 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse int ret = RET_OK; PyObject * filename = NULL; PyObject * tracename = NULL; + PyObject * disposition = NULL; #if WHAT_LOG || TRACE_LOG PyObject * ascii = NULL; #endif @@ -335,41 +336,51 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse /* Check if we should trace this line. */ filename = frame->f_code->co_filename; - tracename = PyDict_GetItem(self->should_trace_cache, filename); - if (tracename == NULL) { + disposition = PyDict_GetItem(self->should_trace_cache, filename); + if (disposition == NULL) { STATS( self->stats.new_files++; ) /* We've never considered this file before. */ /* Ask should_trace about it. */ PyObject * args = Py_BuildValue("(OO)", filename, frame); - tracename = PyObject_Call(self->should_trace, args, NULL); + disposition = PyObject_Call(self->should_trace, args, NULL); Py_DECREF(args); - if (tracename == NULL) { + if (disposition == NULL) { /* An error occurred inside should_trace. */ STATS( self->stats.errors++; ) return RET_ERROR; } - if (PyDict_SetItem(self->should_trace_cache, filename, tracename) < 0) { + if (PyDict_SetItem(self->should_trace_cache, filename, disposition) < 0) { STATS( self->stats.errors++; ) return RET_ERROR; } } else { - Py_INCREF(tracename); + Py_INCREF(disposition); } /* If tracename is a string, then we're supposed to trace. */ + tracename = PyObject_GetAttrString(disposition, "filename"); + if (tracename == NULL) { + STATS( self->stats.errors++; ) + Py_DECREF(disposition); + return RET_ERROR; + } if (MyText_Check(tracename)) { PyObject * file_data = PyDict_GetItem(self->data, tracename); if (file_data == NULL) { file_data = PyDict_New(); if (file_data == NULL) { STATS( self->stats.errors++; ) + Py_DECREF(tracename); + Py_DECREF(disposition); return RET_ERROR; } ret = PyDict_SetItem(self->data, tracename, file_data); Py_DECREF(file_data); if (ret < 0) { STATS( self->stats.errors++; ) + Py_DECREF(tracename); + Py_DECREF(disposition); return RET_ERROR; } } @@ -385,6 +396,7 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse } Py_DECREF(tracename); + Py_DECREF(disposition); self->last_line = -1; break; |