Skip to content

Highlight Python execution traces and embedded source lines - #3981

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:python-trace-output-1955-20260907
Open

Highlight Python execution traces and embedded source lines#3981
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:python-trace-output-1955-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

Python's trace --trace output mixes source locations, optional timing, call headers, and executed source lines. Highlighting it as ordinary Python loses those boundaries.

Add a small Python Trace utility syntax that delegates source text to the existing Python grammar. It highlights filenames, line numbers, elapsed time, function/class declarations, and call headers. Each traced line resets nested parsing because execution can repeat or jump between functions; ordinary program output stays plain. Supports explicit language selection, .pytrace, and first-line detection. The existing Python grammar is unchanged.

Fixes #1955.

Validation: rebuilt and loaded the syntax cache; golden text and color assertions cover timed/untimed lines, declarations, f-strings, comments, filenames with spaces, pseudo-files and recovery after an unfinished multiline string. Real python -m trace --trace output passed text-preservation and color checks with and without --timing. No Rust code changed.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support for colorizing Python trace output

1 participant