Skip to content

Commit 6e87da3

Browse files
committed
Merge pull request matplotlib#589 from efiring/destroy_fig_iterval
_pylab_helpers: don't delete dictionary item while iterating
2 parents b67d327 + f3c8cae commit 6e87da3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/_pylab_helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ def destroy(num):
7272
@staticmethod
7373
def destroy_fig(fig):
7474
"*fig* is a Figure instance"
75+
num = None
7576
for manager in Gcf.figs.itervalues():
7677
if manager.canvas.figure == fig:
77-
Gcf.destroy(manager.num)
78+
num = manager.num
79+
break
80+
if num is not None:
81+
Gcf.destroy(num)
7882

7983
@staticmethod
8084
def destroy_all():

0 commit comments

Comments
 (0)