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

Skip to content

Commit dd8bb2d

Browse files
authored
Merge pull request #17705 from anntzer/uncache-renderer
FIX: Keep cachedRenderer as None when pickling Figure.
2 parents 089b61f + 583e1d9 commit dd8bb2d

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)