]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131763: Replace the redundant check with assert in remove_tools (#131765)
authorSergey Muraviov <smurav@mail.ru>
Wed, 26 Mar 2025 22:36:04 +0000 (01:36 +0300)
committerGitHub <noreply@github.com>
Wed, 26 Mar 2025 22:36:04 +0000 (18:36 -0400)
Python/instrumentation.c

index bcf7267d23b2e30ac9b8acbfd78b7fef6be72545..979047cc6fe2cb4118704dd2b91359b34dd3861a 100644 (file)
@@ -833,14 +833,15 @@ remove_tools(PyCodeObject * code, int offset, int event, int tools)
     assert(PY_MONITORING_IS_INSTRUMENTED_EVENT(event));
     assert(opcode_has_event(_Py_GetBaseCodeUnit(code, offset).op.code));
     _PyCoMonitoringData *monitoring = code->_co_monitoring;
+    assert(monitoring);
     bool should_de_instrument;
-    if (monitoring && monitoring->tools) {
+    if (monitoring->tools) {
         monitoring->tools[offset] &= ~tools;
         should_de_instrument = (monitoring->tools[offset] == 0);
     }
     else {
         /* Single tool */
-        uint8_t single_tool = code->_co_monitoring->active_monitors.tools[event];
+        uint8_t single_tool = monitoring->active_monitors.tools[event];
         assert(_Py_popcount32(single_tool) <= 1);
         should_de_instrument = ((single_tool & tools) == single_tool);
     }