From 2befebd9dfac46fe84fde24979324c373f6487ca Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 19 May 2025 19:39:06 +0200 Subject: [PATCH] Simplify interp_look_up_id() Don't use PyInterpreterState_GetID() but get directly the interpreter 'id' member which cannot fail. --- Python/pystate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Python/pystate.c b/Python/pystate.c index 14ae2748b0bc99..4757a8c3d1476c 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1393,10 +1393,8 @@ interp_look_up_id(_PyRuntimeState *runtime, int64_t requested_id) { PyInterpreterState *interp = runtime->interpreters.head; while (interp != NULL) { - int64_t id = PyInterpreterState_GetID(interp); - if (id < 0) { - return NULL; - } + int64_t id = interp->id; + assert(id >= 0); if (requested_id == id) { return interp; }