@@ -476,19 +476,19 @@ public static Object enter(PythonThreadState threadState, Object[] pArguments, R
476
476
return enter (threadState , pArguments , calleeRootNode .needsExceptionState ());
477
477
}
478
478
479
- private static IndirectCallState enter (PythonThreadState threadState , Object [] pArguments , boolean needsExceptionState ) {
479
+ private static Object enter (PythonThreadState threadState , Object [] pArguments , boolean needsExceptionState ) {
480
480
Reference popTopFrameInfo = threadState .popTopFrameInfo ();
481
481
PArguments .setCallerFrameInfo (pArguments , popTopFrameInfo );
482
482
483
- PException curExc = null ;
484
483
if (needsExceptionState ) {
485
- curExc = threadState .getCaughtException ();
484
+ PException curExc = threadState .getCaughtException ();
486
485
if (curExc != null ) {
487
486
threadState .setCaughtException (null );
488
487
}
489
488
PArguments .setException (pArguments , curExc );
489
+ return new IndirectCallState (popTopFrameInfo , curExc );
490
490
}
491
- return new IndirectCallState ( popTopFrameInfo , curExc ) ;
491
+ return popTopFrameInfo ;
492
492
}
493
493
494
494
public static void exit (PythonLanguage language , PythonContext context , Object state ) {
@@ -501,10 +501,12 @@ public static void exit(PythonThreadState threadState, Object state) {
501
501
* CalleeContext in its RootNode. If this topframeref was marked as escaped, it'll be
502
502
* materialized at the latest needed time
503
503
*/
504
- IndirectCallState indirectCallState = ( IndirectCallState ) state ;
505
- threadState . setTopFrameInfo ( indirectCallState . info ) ;
506
- if (indirectCallState .curExc != null ) {
504
+ if ( state instanceof IndirectCallState ) {
505
+ IndirectCallState indirectCallState = ( IndirectCallState ) state ;
506
+ threadState . setTopFrameInfo (indirectCallState .info );
507
507
threadState .setCaughtException (indirectCallState .curExc );
508
+ } else {
509
+ threadState .setTopFrameInfo ((Reference ) state );
508
510
}
509
511
}
510
512
}
0 commit comments