https://github.com/python/cpython/commit/e79f640eb698df7659c0ce81474d93bf222094c5
commit: e79f640eb698df7659c0ce81474d93bf222094c5
branch: main
author: Victor Stinner <vstin...@python.org>
committer: vstinner <vstin...@python.org>
date: 2025-05-19T18:09:10Z
summary:

Simplify interp_look_up_id() (#134257)

Don't use PyInterpreterState_GetID() but get directly the interpreter
'id' member which cannot fail.

files:
M Python/pystate.c

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;
         }

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to