@@ -113,17 +113,24 @@ public void prepareCall(VirtualFrame frame, Object[] callArguments, RootCallTarg
113113 PArguments .setCallerFrameInfo (callArguments , thisInfo );
114114 }
115115 if (calleeRootNode .needsExceptionState ()) {
116- PException curExc = PArguments .getException (frame );
117- if (curExc == null ) {
118- // bad, but we must provide the exception state
116+ PException curExc = null ;
117+ if (isPythonFrame (frame , callNode )) {
118+ curExc = PArguments .getException (frame );
119+ if (curExc == null ) {
120+ // bad, but we must provide the exception state
119121
120- // TODO: frames: check that this also set
121- // needsExceptionState on our own root node
122- CompilerDirectives .transferToInterpreterAndInvalidate ();
123- PException fromStackWalk = GetCaughtExceptionNode .fullStackWalk ();
124- curExc = fromStackWalk != null ? fromStackWalk : PException .NO_EXCEPTION ;
125- // now, set in our args, such that we won't do this again
126- PArguments .setException (frame , curExc );
122+ // TODO: frames: check that this also set
123+ // needsExceptionState on our own root node
124+ CompilerDirectives .transferToInterpreterAndInvalidate ();
125+ PException fromStackWalk = GetCaughtExceptionNode .fullStackWalk ();
126+ curExc = fromStackWalk != null ? fromStackWalk : PException .NO_EXCEPTION ;
127+ // now, set in our args, such that we won't do this again
128+ PArguments .setException (frame , curExc );
129+ }
130+ } else {
131+ // If we're here, it can only be because some top-level call
132+ // inside Python led us here
133+ curExc = PException .NO_EXCEPTION ;
127134 }
128135 PArguments .setException (callArguments , curExc );
129136 }
0 commit comments