Skip to content

Commit e79f640

Browse files
authored
Simplify interp_look_up_id() (#134257)
Don't use PyInterpreterState_GetID() but get directly the interpreter 'id' member which cannot fail.
1 parent 71c42b7 commit e79f640

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Python/pystate.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,10 +1393,8 @@ interp_look_up_id(_PyRuntimeState *runtime, int64_t requested_id)
13931393
{
13941394
PyInterpreterState *interp = runtime->interpreters.head;
13951395
while (interp != NULL) {
1396-
int64_t id = PyInterpreterState_GetID(interp);
1397-
if (id < 0) {
1398-
return NULL;
1399-
}
1396+
int64_t id = interp->id;
1397+
assert(id >= 0);
14001398
if (requested_id == id) {
14011399
return interp;
14021400
}

0 commit comments

Comments
 (0)