-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-134170: Add colorization to unraisable exceptions #134183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, forgot about this PR!
I think this makes sense for a follow-up, because it'll apply to the current implementation as well, right? Ideally, that test would get backported. In general, we shouldn't have to worry too much about breaking things here, because we're just adding execution of Python code to a path where you could already execute arbitrary Python code. |
Yes. |
Misc/NEWS.d/next/Core_and_Builtins/2025-05-18-10-50-46.gh-issue-134170.J0Hvmi.rst
Outdated
Show resolved
Hide resolved
Python/errors.c
Outdated
Py_XDECREF(result); | ||
if (result != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid checking dangling pointers. Let's do int ok = result != NULL; Py_XDECREF(result);
and compare ok
afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…python into unraisable-color
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry last nitpicks.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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/