Skip to content

gh-113081: Print colorized exception just like built-in traceback in pdb #113082

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

Merged
merged 8 commits into from
May 4, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Dec 14, 2023

This is the first step to colorize pdb - just use the existing colorized traceback for exceptions in post mortem mode. The code change is really trivial and it just calls the colorized version of exception printing in traceback.

Yes, it's using an internal function, but pdb is stdlib so it can adapt when the function is changed. We can also use print_exception but we need traceback._can_colorize() anyway - which should be put into a separate module if we want to colorize more modules.

@gaogaotiantian
Copy link
Member Author

@pablogsal could you share some thoughts on this? Do you think we need extra tests for pdb? Thanks!

@brandtbucher
Copy link
Member

@pablogsal, any thoughts on this simple (colorful!) change? Otherwise I'm inclined to merge. :)

@brandtbucher brandtbucher requested a review from pablogsal May 4, 2024 00:30
@brandtbucher brandtbucher self-assigned this May 4, 2024
@gaogaotiantian
Copy link
Member Author

What is the current proper way to disable color in tests? I thought there was a global mechanism implemented. I can do it for pdb only but want to make sure this is not something that should be covered already.

@brandtbucher
Copy link
Member

Check out test.support.force_not_colorized.

@brandtbucher
Copy link
Member

Looks like test_issue84583 needs a decorator too.

@gaogaotiantian
Copy link
Member Author

Okay seems like the tests passed now. My local tests worked fine and I did not have the time to figure out the difference.

@pablogsal
Copy link
Member

Let's merge it!

@pablogsal pablogsal merged commit 00da0af into python:main May 4, 2024
33 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-colorize-exception branch May 6, 2024 19:43
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants