Skip to content
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

Warn In PyThreadState_Clear() If the Thread State Still Has an Unhandled Exception #121058

Closed
ericsnowcurrently opened this issue Jun 26, 2024 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Jun 26, 2024

Feature or enhancement

Proposal:

When PyThreadState_Clear() is called, the thread state could still have an exception set. As a user, it would be helpful to know when that happens. This is similar to how we already warn the user if the thread state was still running Python code (we check tstate->current_frame).

For unhandled exceptions, I'm pretty sure we'd check tstate->exc_state (or maybe tstate->exc_info), along with tstate->current_exception. We could emit a warning, as well as print the traceback (or generally invoke sys.excepthook()).

It would probably make sense to separately warn about tstate->async_exc (and print that traceback).

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants