Skip to content

Backport PR #17705 on branch v3.3.x (Keep cachedRenderer as None when pickling Figure.) #17717

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,8 +2108,10 @@ def __getstate__(self):
# The canvas cannot currently be pickled, but this has the benefit
# of meaning that a figure can be detached from one canvas, and
# re-attached to another.
for attr_to_pop in ('canvas', '_cachedRenderer'):
state.pop(attr_to_pop, None)
state.pop("canvas")

# Set cached renderer to None -- it can't be pickled.
state["_cachedRenderer"] = None

# add version information to the state
state['__mpl_version__'] = _mpl_version
Expand Down