Keep exception message continuation lines as text - #13
Open
ump45nose wants to merge 1 commit into
Open
Conversation
The catch-all rule in IPythonPartialTracebackLexer tagged every remaining line as Other. IPythonTracebackLexer delegates Other tokens to the Python lexer, so plain-text lines of a multiline exception message were re-lexed as Python code, emitting Error tokens when the message contained characters invalid in Python, such as backticks. Emit Text instead: numbered code-frame lines are matched by earlier rules and still delegate to the Python lexer. Fixes ipython/ipython#14142.
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.
Fixes ipython/ipython#14142
Summary
IPythonPartialTracebackLexerended its rules with a catch-all thattagged every unmatched line as
Other.IPythonTracebackLexeris aDelegatingLexer, soOthertokens are re-lexed with the Python lexer.Continuation lines of a multiline exception message are plain text, not
Python, so e.g. backticks in the message produced
Errortokens thatbroke highlighting (and sphinx/myst-nb builds using
RaiseOnErrorTokenFilter).Numbered code-frame lines are matched by earlier rules whose code part
is still
Other(and therefore still delegated to the Python lexer), sothis change only affects unmatched trailing text.
Changes
ipython_pygments_lexers.py: final fallback rule now emitsTextinstead of
Other, with a comment explaining why.test_ipython_pygments_lexers.py: regression test asserting noErrortokens for a multiline exception message containing backticks,including through
RaiseOnErrorTokenFilter.Tests
pytest→ 8 passed.