Skip to content

_seek_check already raises an EOFError#8773

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:eof
Mar 3, 2025
Merged

_seek_check already raises an EOFError#8773
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:eof

Conversation

@radarhere
Copy link
Copy Markdown
Member

_seek_check raises an EOFError if the user seeks outside of the image.

For MicImagePlugin and PsdImagePlugin, the call to that is enough, and no further error catching needs to be done to handle if seek will take us outside of the image - the EOFError would only be raised if a user deliberately changed self.images (or self.layers in the case of PsdImagePlugin).

def seek(self, frame: int) -> None:
if not self._seek_check(frame):
return
try:
filename = self.images[frame]
except IndexError as e:
msg = "no such frame"
raise EOFError(msg) from e

@hugovk hugovk merged commit 989a358 into python-pillow:main Mar 3, 2025
@radarhere radarhere deleted the eof branch March 3, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants