Skip to content

Commit

Permalink
fix: Fix patching lines in tracebacks on Python 3.13
Browse files Browse the repository at this point in the history
Issue-58: #58
  • Loading branch information
pawamoy committed Jun 24, 2024
1 parent ecc341e commit 917af4c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/markdown_exec/formatters/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def _run_python(
trace = traceback.TracebackException.from_exception(error)
for frame in trace.stack:
if frame.filename.startswith("<code block: "):
frame._line = _code_blocks[frame.filename][frame.lineno - 1] # type: ignore[attr-defined,operator]
if sys.version_info >= (3, 13):
frame._lines = _code_blocks[frame.filename][frame.lineno - 1] # type: ignore[attr-defined,operator]
else:
frame._line = _code_blocks[frame.filename][frame.lineno - 1] # type: ignore[attr-defined,operator]
raise ExecutionError(code_block("python", "".join(trace.format()), **extra)) from error
return buffer.getvalue()

Expand Down

0 comments on commit 917af4c

Please sign in to comment.