Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 987ceb9

Browse filesBrowse files
committed
Fix a missed exception handling for bad plugins
1 parent c907b2e commit 987ceb9
Copy full SHA for 987ceb9

File tree

Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed

‎coverage/ctracer/tracer.c

Copy file name to clipboardExpand all lines: coverage/ctracer/tracer.c
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ CTracer_handle_line(CTracer *self, PyFrameObject *frame)
685685
STATS( self->stats.pycalls++; )
686686
from_to = PyObject_CallMethodObjArgs(self->pcur_entry->file_tracer, str_line_number_range, frame, NULL);
687687
if (from_to == NULL) {
688-
goto error;
688+
CTracer_disable_plugin(self, self->pcur_entry->disposition);
689+
goto ok;
689690
}
690691
ret2 = CTracer_unpack_pair(self, from_to, &lineno_from, &lineno_to);
691692
Py_DECREF(from_to);

‎tests/test_plugins.py

Copy file name to clipboardExpand all lines: tests/test_plugins.py
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,28 @@ def coverage_init(reg, options):
804804
""")
805805
self.run_bad_plugin("bad_plugin", "Plugin")
806806

807+
def test_line_number_range_raises_error(self):
808+
self.make_file("bad_plugin.py", """\
809+
import coverage.plugin
810+
class Plugin(coverage.plugin.CoveragePlugin):
811+
def file_tracer(self, filename):
812+
if filename.endswith("other.py"):
813+
return BadFileTracer()
814+
815+
class BadFileTracer(coverage.plugin.FileTracer):
816+
def source_filename(self):
817+
return "something.foo"
818+
819+
def line_number_range(self, frame):
820+
raise Exception("borked!")
821+
822+
def coverage_init(reg, options):
823+
reg.add_file_tracer(Plugin())
824+
""")
825+
self.run_bad_plugin(
826+
"bad_plugin", "Plugin", our_error=False, excmsg="borked!",
827+
)
828+
807829
def test_line_number_range_returns_non_tuple(self):
808830
self.make_file("bad_plugin.py", """\
809831
import coverage.plugin

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.