-
Notifications
You must be signed in to change notification settings - Fork 788
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
also use PyErr::SetObject
on Python versions before 3.12
#3455
Conversation
b0c696d
to
14d8913
Compare
14d8913
to
3a434e6
Compare
Can you explain how this fixes those issues? I'm reading the code and the C api docs but I don't quite see it. |
I can't speak in detail for the PyPy fix, which is a little bit arcane. My intuition there was that before this PR we were not "normalizing" exceptions from our The motivation for calling Given we're forced to use it on 3.12 to make the machinery work, because |
src/err/err_state.rs
Outdated
/// In principle this could be split in two; first a function to create an exception | ||
/// in a normalized state, and then a call to `PyErr_SetRaisedException` to raise it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also this comment; I think in principle we could implement an equivalent of PyErr_SetObject
in Rust, which would have the upside of allowing us to then refactor and adjust behaviour later if we so desire. I wanted to start by just calling PyErr_SetObject
as it avoids moving a lot of complexity to Rust.
Please review #3471 first. |
3a434e6
to
2daddb4
Compare
PyErr::SetObject
on Python versions before 3.12
Rebased; this PR is now a very minimal diff which hopefully highlights the way that this adjustment makes the pre-3.12 code paths match 3.12, while also fixing a bug (and adding a test). |
As this makes a behavioural change which I believe we want to bring as part of the 0.20 release, I'm going to merge this soon (probably tomorrow) so I can proceed with preparing the release. Please forgive me if this turns out to be unwanted! 🙏 |
Fixes #3432
This PR changes versions before 3.12 to also use
PyErr::SetObject
when raising (or normalizing) a lazy PyErr. This helps to unify the code paths between 3.12 and older versions as well as fixes the bugs discussed in those recent issues.