Skip to content

Commit

Permalink
SpiderImagePlugin: raise an error when seeking in a non-stack file
Browse files Browse the repository at this point in the history
Using ImageSequence.Iterator on a non-stack SPIDER image leads to infinite loop.
EOFError (which stops the iteration) is never raised because when the image isn't a stack,
seek() returns gently without error.
  • Loading branch information
jmichalon authored and radarhere committed Apr 2, 2016
1 parent fd7fa4e commit d07ab52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion PIL/SpiderImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def tell(self):

def seek(self, frame):
if self.istack == 0:
return
raise EOFError("attempt to seek in a non-stack file")
if frame >= self._nimages:
raise EOFError("attempt to seek past end of file")
self.stkoffset = self.hdrlen + frame * (self.hdrlen + self.imgbytes)
Expand Down

0 comments on commit d07ab52

Please sign in to comment.