Repository navigation
Fix callback cleanup while signals are blocked - #32691
hector2394 wants to merge 1 commit into
Conversation
Keep callback registrations available to weakref cleanup while dispatch is blocked.
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
PR summary
Closes #32674.
A listener collected inside
CallbackRegistry.blocked()can raise an unraisableKeyErrorand leave a dead weak reference in the registry. Blocking currently replaces the callback mapping, which weakref cleanup still needs to access.This change keeps registrations available and checks the blocked signals in
process(). Nested blocks restore their previous blocking state on exit, and pickling excludes temporary blocking state.Regression tests cover listener cleanup during global and selective blocks, connecting and disconnecting within nested blocks, and pickling while blocked.
The full
test_cbook.pymodule and targeted color, colorbar and contour callback tests passed. Five optional pandas and xarray cases were skipped. The editable build, Ruff and mypy checks also passed.AI Disclosure
AI agents generated the implementation, regression tests and ran the local checks. I reviewed the code before doing the commit and push.
PR quality check