Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/test/test_cprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def test_second_profiler(self):
pr = self.profilerclass()
pr2 = self.profilerclass()
pr.enable()
self.assertRaises(ValueError, pr2.enable)
pr.disable()
self.addCleanup(pr.disable)
msg = f"tool {sys.monitoring.PROFILER_ID} is already in use"
self.assertRaisesRegex(ValueError, msg, pr2.enable)

def test_throw(self):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :meth:`!cProfile.Profile.enable` to no longer overwrite errors from
:mod:`sys.monitoring`.
1 change: 0 additions & 1 deletion Modules/_lsprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,6 @@ _lsprof_Profiler_enable_impl(ProfilerObject *self, int subcalls,
"use_tool_id", "is",
self->tool_id, "cProfile");
if (check == NULL) {
PyErr_Format(PyExc_ValueError, "Another profiling tool is already active");
goto error;
}
Py_DECREF(check);
Expand Down
Loading