Skip to content

bpo-45711: Use _PyErr_ClearExcState instead of setting only exc_value… #29404

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 2 commits into from
Nov 10, 2021

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Nov 4, 2021

… to NULL

This PR tidies up exception handling in Future/Task._make_cancelled_error to make it clearer what's happening and pave the way for a refactor of how the interpreter represents exceptions.

https://bugs.python.org/issue45711

/* Transfer ownership of exc_value from exc_state to exc since we are
done with it. */
PyException_SetContext(exc, exc_state->exc_value);
exc_state->exc_value = NULL;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that PyErr_Occurred checks whether the type is NULL, not the value. So setting just the value to NULL here doesn't follow the interpreter's semantics for the triplet.

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

LGTM, the PR is correct.

@iritkatriel iritkatriel merged commit 05fbd60 into python:main Nov 10, 2021
@iritkatriel iritkatriel deleted the bpo-45711-type_val_tb branch November 10, 2021 19:20
remykarem pushed a commit to remykarem/cpython that referenced this pull request Dec 7, 2021
remykarem pushed a commit to remykarem/cpython that referenced this pull request Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants