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

always normalize exceptions before raising #3471

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

davidhewitt
Copy link
Member

Split from #3455

It seems like the part of the above PR which needs to be better understood is the use of PyErr_SetObject, so I've split out this PR which just ensures the exception is normalized when raising a "lazy" exception. Given that 3.12 already does this (by virtue of exceptions always being normalized) this is a consistency change for the older Pythons. It fixes the issue observed in #3439 (a test added).

To try to make things a bit simpler I've adjusted code paths a little bit so that PyErrState::normalize has just one implementation with different match arms for pre/post 3.12.

@davidhewitt
Copy link
Member Author

Rebased; this now has a very minimal diff in src/err/err_state.rs and everything else is test code. Hopefully this makes it easier to decide on the change of behaviour.

Copy link
Member

@mejrs mejrs left a comment

Choose a reason for hiding this comment

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

LGTM

@davidhewitt davidhewitt added this pull request to the merge queue Sep 28, 2023
Merged via the queue into PyO3:main with commit 4b5ff05 Sep 28, 2023
61 checks passed
@davidhewitt davidhewitt deleted the normalized-exceptions-2 branch September 28, 2023 22:08
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.

2 participants