-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python console: do not require output that looks like a traceback to be valid #2410
Conversation
Note: alternate fix would be to just allow stray lines in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
As you submitted this I was preparing a change that actually highlights these tracebacks “correctly” (e.g., Generic.Traceback for all "Traceback (...):" lines), but being robust is always good.
The fix is fine, but it produces "one character tokens". Can we track if we're in "error mode" and while we're in error mode, accumulate tokens, and if we're in the first non-error token, yield the whole text accumulated so far? We can also fix this in a subsequent release if this is too much work for now and we want the fix out. |
Hmm, seems like the alternate fix would be better then? If I understand correctly, it means diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index 6c89e6b5..eaaf6476 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -763,7 +763,8 @@ class PythonTracebackLexer(RegexLexer):
(r'^([^:]+)(: )(.+)(\n)',
bygroups(Generic.Error, Text, Name, Whitespace), '#pop'),
(r'^([a-zA-Z_][\w.]*)(:?\n)',
- bygroups(Generic.Error, Whitespace), '#pop')
+ bygroups(Generic.Error, Whitespace), '#pop'),
+ default('#pop'),
],
'markers': [
# Either `PEP 657 <https://www.python.org/dev/peps/pep-0657/>` Right? |
Yeah, true, I like this better then. |
which causes Error to be flagged with console outputs that just happen to look like a traceback Fixes #2407
which causes Error to be flagged with output that just happens to look like a traceback
Fixes #2407