{{ message }}
gh-134170: Add colorization to unraisable exceptions#134183
Merged
Merged
Conversation
picnixz
reviewed
May 18, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz
reviewed
May 18, 2025
picnixz
left a comment
Member
There was a problem hiding this comment.
Let's this by raising an unraisable exception inside the hook itself and check that we don't crash. I don't know if we can recursively call sys.unraisablehook because of that, but if we can, we should check that we don't segfault for whatever reason.
Member
Author
Member
Yes. |
picnixz
reviewed
Aug 3, 2025
Comment on lines
+1497
to
+1498
Member
There was a problem hiding this comment.
Let's avoid checking dangling pointers. Let's do int ok = result != NULL; Py_XDECREF(result); and compare ok afterwards.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…python into unraisable-color
picnixz
reviewed
Aug 3, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
vstinner
reviewed
Aug 4, 2025
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
picnixz
approved these changes
Aug 4, 2025
Agent-Hellboy
pushed a commit
to Agent-Hellboy/cpython
that referenced
this pull request
Aug 19, 2025
…4183) Default implementation of sys.unraisablehook() now uses traceback._print_exception_bltin() to print exceptions with colorized text. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

It's pretty now:
I don't think it's worth it/possible to add a test for this.
sys.unraisablehook#134170📚 Documentation preview 📚: https://cpython-previews--134183.org.readthedocs.build/