File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -328,27 +328,38 @@ PyInterpreterState_GetID(PyInterpreterState *interp)
328
328
329
329
330
330
PyInterpreterState *
331
- _PyInterpreterState_LookUpID (PY_INT64_T requested_id )
331
+ interp_lookup_id (PY_INT64_T requested_id )
332
332
{
333
- if (requested_id < 0 )
334
- goto error ;
335
-
336
333
PyInterpreterState * interp = PyInterpreterState_Head ();
337
334
while (interp != NULL ) {
338
335
PY_INT64_T id = PyInterpreterState_GetID (interp );
339
- if (id < 0 )
336
+ if (id < 0 ) {
340
337
return NULL ;
341
- if (requested_id == id )
338
+ }
339
+ if (requested_id == id ) {
342
340
return interp ;
341
+ }
343
342
interp = PyInterpreterState_Next (interp );
344
343
}
345
-
346
- error :
347
- PyErr_Format (PyExc_RuntimeError ,
348
- "unrecognized interpreter ID %lld" , requested_id );
349
344
return NULL ;
350
345
}
351
346
347
+ PyInterpreterState *
348
+ _PyInterpreterState_LookUpID (PY_INT64_T requested_id )
349
+ {
350
+ PyInterpreterState * interp = NULL ;
351
+ if (requested_id >= 0 ) {
352
+ HEAD_UNLOCK ();
353
+ interp = interp_lookup_id (requested_id );
354
+ HEAD_UNLOCK ();
355
+ }
356
+ if (interp == NULL && !PyErr_Occurred ()) {
357
+ PyErr_Format (PyExc_RuntimeError ,
358
+ "unrecognized interpreter ID %lld" , requested_id );
359
+ }
360
+ return interp ;
361
+ }
362
+
352
363
353
364
int
354
365
_PyInterpreterState_IDInitref (PyInterpreterState * interp )
You can’t perform that action at this time.
0 commit comments