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

bpo-45711: [asyncio] Normalize exceptions immediately after Fetch, before they are stored as StackItem, which should be normalized #29890

Merged

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Dec 2, 2021

The handled exception exc_info (unlike the in-flight exception currexc) is always normalized. Except in asyncio, where unnormalised exceptions are saved in a StackItem and need to be normalized when they are used.

This PR brings asyncio in line with the rest of the code, by normalising exceptions and setting the traceback when they are Fetched.

https://bugs.python.org/issue45711

@iritkatriel
Copy link
Member Author

iritkatriel commented Dec 2, 2021

This broke a couple of the asyncio tests, I'm checking why.

@iritkatriel
Copy link
Member Author

iritkatriel commented Dec 2, 2021

This broke a couple of the asyncio tests, I'm checking why.

Right, because I removed the traceback update, which is not part of the normalising. The tests pass if I put it back.

But I think the right place to do this is when the exception is captured, here

@iritkatriel iritkatriel requested a review from asvetlov Dec 2, 2021
@iritkatriel iritkatriel changed the title bpo-45711: Remove unnecessary normalization of exc_info bpo-45711: [asyncio] Normalize exceptions immediately after Fetch, before they are stored as StackItem, which should be normalized Dec 2, 2021
@iritkatriel iritkatriel marked this pull request as ready for review Dec 2, 2021
@iritkatriel iritkatriel requested a review from 1st1 as a code owner Dec 2, 2021
Python/errors.c Outdated
if (tb2 != NULL) {
PyException_SetTraceback(val2, tb2);
}

Copy link
Member

@gvanrossum gvanrossum Dec 2, 2021

Choose a reason for hiding this comment

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

Is this deletion supposed to be part of this PR? (The PR title didn't indicate a cleanup in errors.c.)

@1st1 should probably review this.

Copy link
Member Author

@iritkatriel iritkatriel Dec 2, 2021

Choose a reason for hiding this comment

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

It is intended, I thought the error.c change doesn’t need to be in news because it’s a private function.

Yes, I’ll wait to hear from @1st1.

Once we have just exc_value in StackItem, I think we should add something like a PyErr_FetchNormalized(&exc) for these cases. Then you use PyErr_Fetch only for Fetch-Restore.

Copy link
Member Author

@iritkatriel iritkatriel Dec 2, 2021

Choose a reason for hiding this comment

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

Actually it's a good point, I'll remove this from this PR so it's just asyncio and @1st1 won't need to worry about this part.

Copy link
Member

@gvanrossum gvanrossum left a comment

LG from me, not sure how long to wait for @1st1.

1st1
1st1 approved these changes Dec 3, 2021
@iritkatriel iritkatriel merged commit 2ff758b into python:main Dec 3, 2021
12 checks passed
@iritkatriel iritkatriel deleted the 45711-exc_info_does_not_need_normalizing branch Dec 8, 2021
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.

None yet

6 participants