You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_pyrepl: Syntax highlighting gets corrupted after in-line editing operations #159674
In 3.16 (main), syntax highlighting breaks (either stale colors or losing colors) when text is inserted or deleted in the middle of the line, instead of being typed sequentially.
Reproducer 1 (Stale color on parenthesis)
Type print() in the REPL.
Press the Left arrow key to move the cursor between ( and ).
Type "Hello".
The final ) is incorrectly highlighted in green.
Reproducer 2 (Losing string color)
Type + "Hello".
Press HOME (move to start of line).
Type "Hello ".
Press LEFT (move cursor left).
Delete a character (e.g., the space).
Press RIGHT.
Type a space.
The second "Hello" and the + sign lose their syntax highlighting and are rendered in default white.
Observation
Typing code continuously from left to right renders the colors correctly.
The highlighting issues only occur when editing existing text (moving the cursor, inserting, or deleting).
I can't reproduce this on current main (b00a140). I built it on Linux and ran both reproducers in a real xterm with TERM=xterm and TERM=xterm-256color, typing slowly and in fast bursts, and the colors come out right every time: print("Hello") ends with a plain ), and the second one ends as "Hello" + "Hello" with both strings green.
One thing about reproducer 2: if step 5 uses the Delete key instead of Backspace, it removes the closing quote rather than the space, so the line becomes "Hello + "Hello". The second Hello is then outside a string, so showing it uncolored is correct. Also, + and ) have no color in the default theme, so they should always look like plain text.
Could you share the output of python -VV, which terminal emulator you use (and its version), and echo $TERM? If it still happens for you, running PYREPL_TRACE=/tmp/pyrepl.log python and attaching that log would show exactly what the REPL redrew on each keystroke.
Activity
lazerg commentedon Oct 18, 2026
I can't reproduce this on current main (b00a140). I built it on Linux and ran both reproducers in a real xterm with
TERM=xtermandTERM=xterm-256color, typing slowly and in fast bursts, and the colors come out right every time:print("Hello")ends with a plain), and the second one ends as"Hello" + "Hello"with both strings green.One thing about reproducer 2: if step 5 uses the Delete key instead of Backspace, it removes the closing quote rather than the space, so the line becomes
"Hello + "Hello". The secondHellois then outside a string, so showing it uncolored is correct. Also,+and)have no color in the default theme, so they should always look like plain text.Could you share the output of
python -VV, which terminal emulator you use (and its version), andecho $TERM? If it still happens for you, runningPYREPL_TRACE=/tmp/pyrepl.log pythonand attaching that log would show exactly what the REPL redrew on each keystroke.nsyhykui commentedon Oct 18, 2026
Thanks for checking! Here is the
python -VVoutput:Python 3.16.0a1+dev (heads/main:0fedf78, Oct 18 2026, 08:16:21) [Clang 19.1.7 (3+b1)]For Reproducer 2, I double-checked and I actually used the
Backspacekey (deleting the space), notDelete.For both reproducers, I cannot reproduce them in a normal terminal like
xterm. They only happen in my specific terminal emulator (Termux on Android).So this does not seem to be a CPython bug. I'll close this issue as not planned. Thanks for pointing me to the trace tool and for your help!
pyrepl.log