Skip to content

Commit 0c42b4f

Browse files
committed
Fix: exception may have no traceback.
1 parent 87c43fb commit 0c42b4f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,14 @@ public Object run(VirtualFrame frame,
295295
PTraceback exceptionTraceback = getTracebackNode.execute(frame, exception);
296296
// n.b. a call to 'sys.exc_info' always creates a new traceback with the current
297297
// frame and links (via 'tb_next') to the traceback of the exception
298-
PTraceback chainedTraceback = factory().createTraceback(escapedFrame, exceptionTraceback);
298+
PTraceback chainedTraceback;
299+
if (exceptionTraceback != null) {
300+
chainedTraceback = factory().createTraceback(escapedFrame, exceptionTraceback);
301+
} else {
302+
// it's still possible that there is no traceback if, for example, the exception
303+
// has been thrown and caught and did never escape
304+
chainedTraceback = factory().createTraceback(escapedFrame, currentException);
305+
}
299306
exception.setTraceback(chainedTraceback);
300307
return factory().createTuple(new Object[]{getClassNode.execute(exception), exception, chainedTraceback});
301308
}

0 commit comments

Comments
 (0)