summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/ctracer/tracer.c3
-rw-r--r--tests/test_plugins.py22
2 files changed, 24 insertions, 1 deletions
diff --git a/coverage/ctracer/tracer.c b/coverage/ctracer/tracer.c
index 7d639112..50808642 100644
--- a/coverage/ctracer/tracer.c
+++ b/coverage/ctracer/tracer.c
@@ -685,7 +685,8 @@ CTracer_handle_line(CTracer *self, PyFrameObject *frame)
STATS( self->stats.pycalls++; )
from_to = PyObject_CallMethodObjArgs(self->pcur_entry->file_tracer, str_line_number_range, frame, NULL);
if (from_to == NULL) {
- goto error;
+ CTracer_disable_plugin(self, self->pcur_entry->disposition);
+ goto ok;
}
ret2 = CTracer_unpack_pair(self, from_to, &lineno_from, &lineno_to);
Py_DECREF(from_to);
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index 2477f5ce..ed58c5f4 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -804,6 +804,28 @@ class BadFileTracerTest(FileTracerTest):
""")
self.run_bad_plugin("bad_plugin", "Plugin")
+ def test_line_number_range_raises_error(self):
+ self.make_file("bad_plugin.py", """\
+ import coverage.plugin
+ class Plugin(coverage.plugin.CoveragePlugin):
+ def file_tracer(self, filename):
+ if filename.endswith("other.py"):
+ return BadFileTracer()
+
+ class BadFileTracer(coverage.plugin.FileTracer):
+ def source_filename(self):
+ return "something.foo"
+
+ def line_number_range(self, frame):
+ raise Exception("borked!")
+
+ def coverage_init(reg, options):
+ reg.add_file_tracer(Plugin())
+ """)
+ self.run_bad_plugin(
+ "bad_plugin", "Plugin", our_error=False, excmsg="borked!",
+ )
+
def test_line_number_range_returns_non_tuple(self):
self.make_file("bad_plugin.py", """\
import coverage.plugin