@@ -409,7 +409,9 @@ private static IndirectCallState enter(VirtualFrame frame, PythonThreadState pyt
409
409
public static void exit (VirtualFrame frame , PythonLanguage language , PythonContext context , Object savedState ) {
410
410
if (savedState != null && frame != null && context != null ) {
411
411
exit (frame , context .getThreadState (language ), savedState );
412
+ return ;
412
413
}
414
+ assert savedState == null : "tried to exit an indirect call with state, but without frame/context" ;
413
415
}
414
416
415
417
public static void exit (VirtualFrame frame , PNodeWithRaiseAndIndirectCall indirectCallNode , Object savedState ) {
@@ -418,24 +420,28 @@ public static void exit(VirtualFrame frame, PNodeWithRaiseAndIndirectCall indire
418
420
if (context != null ) {
419
421
PythonLanguage language = indirectCallNode .getLanguage ();
420
422
exit (frame , context .getThreadState (language ), savedState );
423
+ return ;
421
424
}
422
425
}
426
+ assert savedState == null : "tried to exit an indirect call with state, but without frame/context" ;
423
427
}
424
428
425
429
/**
426
430
* @see #exit(VirtualFrame, PythonLanguage, PythonContext, Object)
427
431
*/
428
432
public static void exit (VirtualFrame frame , PythonThreadState pythonThreadState , Object savedState ) {
429
- if (frame == null || savedState == null ) {
433
+ if (frame == null ) {
434
+ assert savedState == null : "tried to exit an indirect call with state, but without frame" ;
435
+ return ;
436
+ }
437
+ if (savedState == null ) {
430
438
return ;
431
439
}
432
440
IndirectCallState state = (IndirectCallState ) savedState ;
433
441
if (state .info != null ) {
434
442
pythonThreadState .popTopFrameInfo ();
435
443
}
436
- if (state .curExc != null ) {
437
- pythonThreadState .setCaughtException (state .curExc );
438
- }
444
+ pythonThreadState .setCaughtException (state .curExc );
439
445
}
440
446
}
441
447
0 commit comments