-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-125593: Use colors to highlight error locations in tracebacks from exception group #125681
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
Conversation
wrongnull
commented
Oct 18, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: colors are missing on (Base)ExceptionGroup tracebacks in the pyrepl #125593
Lib/test/test_traceback.py
Outdated
self.assertIn(f"{red}1 {reset+boldr}/{reset+red} 0{reset}", actual) | ||
self.assertIn(f"{red}~~{reset+boldr}^{reset+red}~~{reset}", actual) |
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.
We also need to test for the presence of the magenta color, and, more importantly, we need to ensure that the exception group has been colored and that their sub-exception have also been colored.
@pablogsal @Yhg1s I think this is on the boundary between a bug fix and a feature, so I wanted to ask for your opinion on backporting it to the 3.13 branch. This pull request is pretty trivial, so I would like to consider it a bug fix. |
It's 100% bug, colors should apply to all exceptions, not just normal ones (as it's documented). |
Yes, treating this as a bug seems correct, given that the traceback is now partially colourised. |
I'm converting it to a draft while I struggle with test debugging. |
I definitely underestimated myself |
We can't just construct a expected string and compare it's to the actual message from traceback due to that fact that on Windows x86 <object at 0x...> can't be constructed using the f"<object at {hex(id(obj))}>" because it has different formatting for pointers...:
@pablogsal What do you think? Is the current approach looks good to you or it need to be more generic? |
You could use the real |
I can't. Since pointer formatting is implementation-defined behavior, 32-bit MSVC omits leading zero in formatted string |
I apologize for the misunderstanding. Appropriate changes have been made. |
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.
@pablogsal what do you think about the current approach to testing it?
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
Thanks @wrongnull for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks a lot for the fix @wrongnull and thanks for the review @Eclips4 ! |
…s from exception group (pythonGH-125681) (cherry picked from commit 51b012b) Co-authored-by: Bogdan Romanyuk <[email protected]>
GH-126021 is a backport of this pull request to the 3.13 branch. |
…s from exception group (python#125681)