cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-139167: Allow users to hook gen_colors function to pyrepl Reader

Open gaogaotiantian opened this issue 2 months ago • 2 comments

I'm working on using pyrepl for pdb (at least most of it). I like the real-time color rendering for user's code, but we need some modification for pdb. The user could type a pdb command or a piece of valid python code. The problem now is we have some pdb commands that are either keywords or builtins (continue, break, list). We probably want to make all pdb commands the same color.

In order to do that, we can create a customized gen_colors function for pdb - use the original gen_colors mostly, but with some extra checks on the first word.

However, there's no way to hook that into pyrepl now. I think this change should be trivial enough without breaking the existing code or making the code base too messy. We already have plenty of code that changes the Reader object at run-time so that won't be an exception either.

  • Issue: gh-139167

gaogaotiantian avatar Nov 16 '25 08:11 gaogaotiantian

@ambv could you take a look when you have some time? I believe you implemented the original feature for real-time color in REPL.

gaogaotiantian avatar Nov 20 '25 02:11 gaogaotiantian

Friendly ping @ambv if you have some time to check this PR

gaogaotiantian avatar Jan 04 '26 06:01 gaogaotiantian