Skip to content

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

Merged
merged 32 commits into from
Aug 4, 2025

Conversation

ZeroIntensity
Copy link
Member

@ZeroIntensity ZeroIntensity commented May 18, 2025

It's pretty now:

image

I don't think it's worth it/possible to add a test for this.


📚 Documentation preview 📚: https://cpython-previews--134183.org.readthedocs.build/

Copy link
Member

@picnixz picnixz left a 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.

@ZeroIntensity
Copy link
Member Author

Sorry, forgot about this PR!

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.

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.

@picnixz
Copy link
Member

picnixz commented Jun 2, 2025

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.

Yes.

@ZeroIntensity ZeroIntensity requested a review from picnixz August 3, 2025 18:03
Python/errors.c Outdated
Comment on lines 1497 to 1498
Py_XDECREF(result);
if (result != NULL) {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@picnixz picnixz left a 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>
ZeroIntensity and others added 2 commits August 4, 2025 09:05
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ZeroIntensity ZeroIntensity enabled auto-merge (squash) August 4, 2025 14:10
@ZeroIntensity ZeroIntensity merged commit e8251dc into python:main Aug 4, 2025
41 checks passed
@ZeroIntensity ZeroIntensity deleted the unraisable-color branch August 4, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy