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

Skip to content

Commit b57c6dc

Browse files
committed
Check if iterator has length
If an iterable is passed into `FuncAnimation` check if it has `__len__` before trying to take it's length closes #1769
1 parent 350320f commit b57c6dc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/matplotlib/animation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,8 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
10001000
self._iter_gen = frames
10011001
elif iterable(frames):
10021002
self._iter_gen = lambda: iter(frames)
1003-
self.save_count = len(frames)
1003+
if hasattr(frames, '__len__'):
1004+
self.save_count = len(frames)
10041005
else:
10051006
self._iter_gen = lambda: xrange(frames).__iter__()
10061007
self.save_count = frames

0 commit comments

Comments
 (0)