-
-
Notifications
You must be signed in to change notification settings - Fork 644
Fixed a bug with tracking our active contexts #8211
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
Conversation
e5b57e1 to
48a9d37
Compare
|
While conceptually this can/should be backported to 6.0/6.1, it does change quite a bit with private behavior, so I'm fine with keeping it to 7.0. The likelihood of this bug affecting users in the wild is low, and the consequence is simply that a warning is not being emitted when it should be. |
| if (removed := ACTIVE_CONTEXTS.pop()) != self._context_name: | ||
| raise RuntimeError(f"Cannot remove {self._context_name} from tracking stack because {removed} is last active.") |
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.
Codecov says no test? I am not sure this is worth testing but I leave that up to you.
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.
A test feels a little unpalatable to write because this condition should never be satisfied with normal code. Someone would need to intentionally modify the tracking registry directly while within contexts, and if someone is going to do that, basically all bets are off.
…1-on-7.0 Backport PR #8211 on branch 7.0 (Fixed a bug with tracking our active contexts)
#7437 added a warning when both the
assume_spherical_screen()(now,SphericalScreen()) andpropagate_with_solar_surface()context managers were used together, but there is a bug in the implementation of tracking active contexts that gets confused if a given context manager is used multiple times in a nested structure, e.g.:This PR overhauls the internal tracking of context managers to use the data structure of a stack instead of an unordered set (which was peculiarly implemented as a dictionary of True/False values). Now the tracking respects the nesting of contexts and can handle repeated contexts. Plus, the contexts are stored as fully qualified names, which should avoid potential collisions.