Skip to content

Commit 2c1208b

Browse files
committed
Preserve cProfile enable errors
1 parent 0621639 commit 2c1208b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/test/test_profiling/test_tracing_profiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ def test_second_profiler(self):
118118
pr = self.profilerclass()
119119
pr2 = self.profilerclass()
120120
pr.enable()
121-
self.assertRaises(ValueError, pr2.enable)
122-
pr.disable()
121+
self.addCleanup(pr.disable)
122+
msg = f"tool {sys.monitoring.PROFILER_ID} is already in use"
123+
self.assertRaisesRegex(ValueError, msg, pr2.enable)
123124

124125
def test_throw(self):
125126
"""

Modules/_lsprof.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,6 @@ _lsprof_Profiler_enable_impl(ProfilerObject *self, int subcalls,
821821
"use_tool_id", "is",
822822
self->tool_id, "cProfile");
823823
if (check == NULL) {
824-
PyErr_Format(PyExc_ValueError, "Another profiling tool is already active");
825824
goto error;
826825
}
827826
Py_DECREF(check);

0 commit comments

Comments
 (0)