-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix AttributeError for pickle load of Figure class #23462
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
Reproducible example:
Outcome:
|
…nd_mod function in Figure.__setstate__
ea0363d
to
30da817
Compare
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter 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.
We already have tests for pickling; I assume they didn't catch this because it's all in the same process. We definitely need a test to be sure that this is working. |
This is another fallout from making backend setup lazier in pyplot (previously we would call I suspect https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-tmp-path-fixture + matplotlib/lib/matplotlib/testing/__init__.py Lines 53 to 66 in 4455dc9
|
7d5f53a
to
2a3de64
Compare
2a3de64
to
3c5c2f8
Compare
@tacaswell @QuLogic We create and pickle the figure in the main process. Next we run the I am not sure why the Also one more point. When creating the test I came across a strange bug. I described it in this issue #23471 |
The CI errors are
But I don't see that this PR should have caused that.... |
I think the docs failure is related to hosting issues (which were resolved by our providers), re-restarted docs build. |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
Thanks @wsykala! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
There are same pretty big changes in the test file on main that are not an 3.5.x (for example the pickle test went to an figures equal test from an image comparison test!). I'm inclined to backport this without backporting the tests. It is not ideal, but I think it is less bad than re-writing the tests to not confilct (and dealing with a messy merge up) or implicitly backporting a bunch of other changes to the tests. |
Discussed on the call. Plan: copy the tests back and accept the code duplication and clean it up on merge up. |
…igure class There were a number of complications with the backport: - the new test generalized an existing test that had picked up additional changes on the main branch - the signature of the subproccess helper has changed on the main branch
…-v3.5.x Backport PR #23462: Fix AttributeError for pickle load of Figure class
PR Summary
When saving a figure with the
pickle
module in onepython
process and then loading it in a different process a following error appears:This PR replaces the
plt._backend_mod
with the call toplt._get_backend_mod()
in theFigure.__setstate__
method. This change ensures that the_backend_mod
is notNone
duringpickle
load.A reproducible example is provided in the comments
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).