Skip to content

Commit 9d2beb1

Browse files
committed
Set PException.message when leaving Python
1 parent 58bfca4 commit 9d2beb1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/TopLevelExceptionHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ private PException handlePythonException(PBaseException pythonException) {
171171
throw new PythonExitException(this, 1);
172172
}
173173
}
174-
throw pythonException.getExceptionForReraise(pythonException.getTraceback());
174+
// Before we leave Python, format the message since outside the context
175+
PException exceptionForReraise = pythonException.getExceptionForReraise(pythonException.getTraceback());
176+
PythonObjectLibrary pythonObjectLibrary = PythonObjectLibrary.getUncached();
177+
exceptionForReraise.setMessage(exceptionForReraise.getUnreifiedException().getFormattedMessage(pythonObjectLibrary, pythonObjectLibrary));
178+
throw exceptionForReraise;
175179
}
176180

177181
@TruffleBoundary

0 commit comments

Comments
 (0)