gh-136924: Suspend REPL colorizing when in a REPL interactive command #136926
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.
The proposed solution fixes the issuedescribed in #136924, following the logic of how history doesn't remember what was inside the interactive commands like
help
.BEFORE:
AFTER:
While the fix is small I am having a hard time writing tests for it. Other colorization tests are inside
test_reader.py
, but unfortunately the suspension logic for colors gets triggered outside the Reader class, so a test like this fails:Since that wouldn't work I tried adding a test inside
test_interact
, like:but the console doesn't have access to the reader.screen and I couldn't see the colored output. (There is a small hack that we can do, if the test fails and we capture the result in stderr we can see the bytes, but this didn't feel right 😃 ).
I wanted to confirm this is the approach we want to go with, before potentially investing more time in the tests.
Looking forward to your thoughts, @ambv !