Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix traceback in with / try: finally: for Python 3.10
  • Loading branch information
t-vi committed Jun 5, 2025
commit 9ccc269467b14c5687eefe55929763710b6e5f43
2 changes: 1 addition & 1 deletion thunder/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7342,7 +7342,7 @@ def _run_frame(
runtimectx.exception_stack[-1] = current_exception
with frame.interpreter_stack.set_cur_instruction(PseudoInst.EXCEPTION_HANDLER):
frame.interpreter_stack.append(
current_exception.__traceback__ if exc is not None else None
current_exception.__traceback__ if current_exception is not None else None
)
frame.interpreter_stack.append(current_exception)
# Python distinguishes explicit exc_type present or NULL/None
Expand Down
19 changes: 19 additions & 0 deletions thunder/tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3559,3 +3559,22 @@ def fn(x):
res = jfn(x)
expected = fn(x)
assert_close(res, expected)


def test_reraise_traceback():
import traceback

def bar():
print("A" * "A")

def fn():
try:
bar()
finally:
pass

jfn = thunder.jit(fn)
try:
jfn()
except Exception as e:
assert 'print("A" * "A")' in "\n".join(traceback.format_tb(e.__traceback__))
Loading