Repository navigation
gh-162340: Color exceptions from while REPL awaits input - #162343
johnslavik wants to merge 3 commits into
Conversation
I've included `test_keyboard_interrupt_preserves_last_exception` as an invariant test, inspired by a catch in pythonGH-157241.
| console.resetbuffer() | ||
| except MemoryError: | ||
| console.write("\nMemoryError\n") | ||
| except MemoryError as exc: |
There was a problem hiding this comment.
Can we keep a fallback here? If the traceback formatter runs out of memory, its MemoryError escapes the input loop.
There was a problem hiding this comment.
Fixed. FYI: I knew about this, but wasn't sure about the decision to make. According to some numbers my clankers made, the chance of traceback formatter running out of memory again was rare (but it was a regression indeed). But in retrospective I agree the trivial write is better to avoid regressing over fancy coloring.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @pablogsal: please review the changes made to this pull request. |
a2fe9f4 to
042a239
Compare
Before:
After:
Some notes:
._excepthook()will use.write()at all times._excepthook()fitted really well here because it addresses all coloring concerns and doesn't touchsys.last_*like._showtraceback()test_keyboard_interrupt_preserves_last_exceptionas an invariant test, inspired by a catch in gh-122622: Add PyREPL simple_interact.statement_submitted_hook #157241.MemoryErrorhere__cause__and__context__are still honored), but that is not expected to happen in practiceKeyboardInterruptmessage #162340