This commit is contained in:
Andrew Murray 2026-02-03 21:41:43 +11:00 committed by GitHub
commit 68d088224b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -85,6 +85,11 @@ def test_eoferror() -> None:
# Test that seeking to the last frame does not raise an error
im.seek(n_frames - 1)
# Test seeking past the last frame without calling n_frames first
with Image.open(test_file) as im:
with pytest.raises(EOFError):
im.seek(3)
def test_seek_tell() -> None:
with Image.open(test_file) as im:

View File

@ -175,6 +175,9 @@ class PsdImageFile(ImageFile.ImageFile):
raise self._fp.ex
# seek to given layer (1..max)
if layer > len(self.layers):
msg = "no more images in PSD file"
raise EOFError(msg)
_, mode, _, tile = self.layers[layer - 1]
self._mode = mode
self.tile = tile