From: Victor Stinner Date: Mon, 19 May 2025 18:09:10 +0000 (-0400) Subject: Simplify interp_look_up_id() (#134257) X-Git-Tag: v3.15.0a1~1655 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e79f640eb698df7659c0ce81474d93bf222094c5;p=thirdparty%2FPython%2Fcpython.git Simplify interp_look_up_id() (#134257) Don't use PyInterpreterState_GetID() but get directly the interpreter 'id' member which cannot fail. --- diff --git a/Python/pystate.c b/Python/pystate.c index 14ae2748b0bc..4757a8c3d147 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; }