Skip to content

gh-113081: Highlight source code in pdb #133355

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 5 commits into from
May 5, 2025

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented May 3, 2025

With #131507, we have some convenient interface to colorize a piece of code. We are so close to beta freeze so I'm not trying to achieve some full colorization on pdb. This PR introduces the most essential and simple piece - static source code. Basically it only colorizes source code display like ll, l, source, where and the initial stack entry display. I think the ROI is great here.

To make it safe for debuggers based on pdb, this uses the same mechanism as backend - default to False, and only enabled when pdb is explicitly brought up by breakpoint() or python -m pdb. The debuggers that inherit pdb won't be affected.

The double protection from if self.colorize is intentional - we don't know what could happen in the future so I used it for both _colorize_code and in the functions that call it.


📚 Documentation preview 📚: https://cpython-previews--133355.org.readthedocs.build/

@gaogaotiantian gaogaotiantian requested review from iritkatriel and ambv May 3, 2025 18:58
@gaogaotiantian
Copy link
Member Author

Hi @ambv , I know it's kind of last minute feature, but I do think it is very cool to syntax-highlight the code in pdb. You are super familiar with the colorization part and I'm just using the existing interface (I hope it's correct). Could you take a look at it? Thanks!

@ambv
Copy link
Contributor

ambv commented May 5, 2025

Excellent, I was thinking that you might want to do that. Looks great!

@ambv ambv merged commit ff4959b into python:main May 5, 2025
39 checks passed
@gaogaotiantian gaogaotiantian deleted the colorize-pdb-list branch May 5, 2025 17:49
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