refactor PyErr
state to reduce blast radius of threading challenge
#4650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First step towards solving #4584.
Whether we drop the lazy state or not, the first step seems to be to clean up the
PyErr
implementation so that the location of the threading problem is fully localised withinerr_state.rs
.I do this by wrapping the
UnsafeCell<Option<PyErrState>>
as a newPyErrState
struct and rename the original state enum toPyErrStateInner
. The normalPyErr
methods now can't even see thePyErrStateInner
enum (and have to go through the.normalized()
helper onPyErrState
).This is a pure refactoring without any behaviour changes, we can decide on behaviour changes in future PRs.