Repository navigation
Line-wrapped syntax highlighting in Python shell spills over into program output #152068
Copy link
Copy link
Open
Open
Copy link
Labels
OS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jun 24, 2026 This seems to me like an ANSI issue. Is this with the default Terminal.app or some other?
Edit: It appears the code explicitly singles out Terminal.app
cpython/Lib/_pyrepl/unix_console.py
Lines 215 to 218 in 6c3da17
self.is_apple_terminal = ( platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal" )
and overrides the line wrapping
cpython/Lib/_pyrepl/unix_console.py
Lines 493 to 496 in 6c3da17
# Apple Terminal will re-wrap lines for us unless we preempt the # damage. if self.is_apple_terminal: os.write(self.output_fd, b"\033[?7l")
which could be causing the bug of the reset ANSI escape code not being appended properly to the second line.Reacted by DroneBetter- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shell
on Jun 24, 2026 - Reacted by DroneBetter
Thanks for the information. I'm not on a mac however, so I can't reproduce it anyway.
Thanks for the information. I'm not on a mac however, so I can't reproduce it anyway.
Ah that's right I forgot haha. It is a flaky use case but tried the fix and seems to work :)
- added a commit that references this issue
on Jun 25, 2026
Metadata
Metadata
Assignees
Labels
OS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error



Bug report
Bug description:
As shown here, when I make the input long enough that the

rangegets wrapped with a backtick, all subsequent lines until the next command prompt become the same cyan as the text ofrange.Tangentially, is there any way to have Python itself stop doing this when the VScode terminal already did it for me in a way I find preferable (since it doesn't insert line-breaks into long one-liners copied from the shell)?
issue 140334 is similar, but this affects the shell, not just IDLE.
CPython versions tested on:
3.14
Operating systems tested on:
macOS, in both VScode and the terminal.
Linked PRs