diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 0af2070b5cd983..806d3fbf5d6b19 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -989,8 +989,12 @@ call_one_instrument( if (res == NULL) { return -1; } + if (res == &_PyInstrumentation_DISABLE) { + assert(_Py_IsImmortal(res)); + return 1; + } Py_DECREF(res); - return (res == &_PyInstrumentation_DISABLE); + return 0; } static const int8_t MOST_SIGNIFICANT_BITS[16] = {