|
63 | 63 | import com.oracle.graal.python.runtime.exception.PException;
|
64 | 64 | import com.oracle.graal.python.util.PythonUtils;
|
65 | 65 | import com.oracle.truffle.api.CompilerDirectives;
|
| 66 | +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
66 | 67 | import com.oracle.truffle.api.TruffleLanguage;
|
67 | 68 | import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
68 | 69 | import com.oracle.truffle.api.dsl.GenerateNodeFactory;
|
@@ -106,18 +107,23 @@ public Object execute(VirtualFrame frame) {
|
106 | 107 | try {
|
107 | 108 | return callNode.execute(null, callable, arguments, keywords);
|
108 | 109 | } catch (PException e) {
|
109 |
| - PBaseException pythonException = e.getEscapedException(); |
110 |
| - PythonObjectLibrary lib = PythonObjectLibrary.getUncached(); |
111 |
| - if (!IsBuiltinClassProfile.profileClassSlowPath(lib.getLazyPythonClass(pythonException), PythonBuiltinClassType.SystemExit)) { |
112 |
| - lib.lookupAndCallRegularMethod(context.getCore().getStderr(), null, "write", "Error in atexit._run_exitfuncs:\n"); |
113 |
| - ExceptionUtils.printExceptionTraceback(context, pythonException); |
114 |
| - } |
| 110 | + handleException(context, e); |
115 | 111 | throw e;
|
116 | 112 | } finally {
|
117 | 113 | context.popTopFrameInfo();
|
118 | 114 | context.setCaughtException(null);
|
119 | 115 | }
|
120 | 116 | }
|
| 117 | + |
| 118 | + @TruffleBoundary |
| 119 | + private static void handleException(PythonContext context, PException e) { |
| 120 | + PBaseException pythonException = e.getEscapedException(); |
| 121 | + PythonObjectLibrary lib = PythonObjectLibrary.getUncached(); |
| 122 | + if (!IsBuiltinClassProfile.profileClassSlowPath(lib.getLazyPythonClass(pythonException), PythonBuiltinClassType.SystemExit)) { |
| 123 | + lib.lookupAndCallRegularMethod(context.getCore().getStderr(), null, "write", "Error in atexit._run_exitfuncs:\n"); |
| 124 | + ExceptionUtils.printExceptionTraceback(context, pythonException); |
| 125 | + } |
| 126 | + } |
121 | 127 | }
|
122 | 128 |
|
123 | 129 | @Specialization
|
|
0 commit comments