From 48c2d371ea86ddc0cdad30601b7a0e118fa3ce70 Mon Sep 17 00:00:00 2001 From: stevens Date: Fri, 7 Aug 2026 23:34:10 +0800 Subject: [PATCH] gh-151524: Make it clearer that `_PyInstrumentation_DISABLE` is immortal in the code (GH-151525) (cherry picked from commit 52bed26b79cc0333f1b26fd144488e4b38ebd0b5) Co-authored-by: stevens --- Python/instrumentation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 51bcbfdb3b6c55b..646fc15c6872e56 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] = {