Skip to content

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 ambv and iritkatriel 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
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
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