Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f7ea2b3

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #17705: Keep cachedRenderer as None when pickling Figure.
1 parent 2199e3e commit f7ea2b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/figure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,8 +2108,10 @@ def __getstate__(self):
21082108
# The canvas cannot currently be pickled, but this has the benefit
21092109
# of meaning that a figure can be detached from one canvas, and
21102110
# re-attached to another.
2111-
for attr_to_pop in ('canvas', '_cachedRenderer'):
2112-
state.pop(attr_to_pop, None)
2111+
state.pop("canvas")
2112+
2113+
# Set cached renderer to None -- it can't be pickled.
2114+
state["_cachedRenderer"] = None
21132115

21142116
# add version information to the state
21152117
state['__mpl_version__'] = _mpl_version

0 commit comments

Comments
 (0)