gh-154470: Fix spurious ^J in pdb's colorized list command#154473
Open
ambv wants to merge 1 commit into
Open
Conversation
pdb's `list` colorizes each source line with `_colorize_code`, which feeds it to `_pyrepl.utils.disp_str`. `disp_str` renders control characters in caret notation, so the trailing newline of each source line became a literal "^J". `_print_lines` only stripped the line *after* colorizing, and rstrip() cannot remove the embedded caret sequence. Strip the line before colorizing, matching what `where` already does via `format_stack_entry`. Add a test that attaches with colorize enabled, runs `list`, and asserts no "^J" leaks into the source lines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
I agree that the better way is to strip before colorize. However the is the test more complicated than it needs to be? We don't need remote pdb to trigger this issue - a local one would do. We missed it probably we normalized the white spaces in doctests? BTW I'm aware of this issue a while ago but did not get the time to fix it. Planned to fix before 3.15.0 official release. Sorry about that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pdb's
listcolorizes each source line with_colorize_code, which feeds it to_pyrepl.utils.disp_str.disp_strrenders control characters in caret notation, so the trailing newline of each source line became a literal "^J"._print_linesonly stripped the line after colorizing, and rstrip() cannot remove the embedded caret sequence.Strip the line before colorizing, matching what
wherealready does viaformat_stack_entry. Add a test that attaches with colorize enabled, runslist, and asserts no "^J" leaks into the source lines.Broken by gh-146584.
listcommand output contains trailing ^J markers #154470