mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-12 16:24:45 +03:00
IcoImagePlugin: raise specific exception like CurImagePlugin if no images
This commit is contained in:
parent
583dd3b424
commit
b7055aeaba
BIN
Tests/images/no_icons.ico
Normal file
BIN
Tests/images/no_icons.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 6 B |
|
@ -229,3 +229,8 @@ def test_draw_reloaded(tmp_path):
|
|||
|
||||
with Image.open(outfile) as im:
|
||||
assert_image_equal_tofile(im, "Tests/images/hopper_draw.ico")
|
||||
|
||||
|
||||
def test_empty():
|
||||
with pytest.raises(SyntaxError, match="No images were found"):
|
||||
IcoImagePlugin.IcoImageFile("Tests/images/no_icons.ico")
|
||||
|
|
|
@ -172,6 +172,10 @@ class IcoFile:
|
|||
|
||||
self.entry.append(icon_header)
|
||||
|
||||
if not self.entry:
|
||||
msg = "No images were found"
|
||||
raise TypeError(msg)
|
||||
|
||||
self.entry = sorted(self.entry, key=lambda x: x["color_depth"])
|
||||
# ICO images are usually squares
|
||||
# self.entry = sorted(self.entry, key=lambda x: x['width'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user