gh-139167: Allow users to hook gen_colors function to pyrepl Reader #141619
+5
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_colorsfunction for pdb - use the originalgen_colorsmostly, 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
Readerobject at run-time so that won't be an exception either.