From bdf1c3aeaea705053d9ac6fe335d2be758ea37ff Mon Sep 17 00:00:00 2001 From: "Bora M. Alper" Date: Sun, 21 Jun 2020 11:29:29 +0300 Subject: [PATCH] Handle ValueError ("not enough image data") on Image.open gracefully --- nm_iconfinder/nm_iconfinder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nm_iconfinder/nm_iconfinder.py b/nm_iconfinder/nm_iconfinder.py index b4c8dbe..9602009 100644 --- a/nm_iconfinder/nm_iconfinder.py +++ b/nm_iconfinder/nm_iconfinder.py @@ -42,7 +42,7 @@ def from_url(cls, url: str) -> Optional["Icon"]: with BytesIO(res.content) as bio: try: img = Image.open(bio) - except UnidentifiedImageError: + except (UnidentifiedImageError, ValueError): return None width, height = img.size # Ignore non-square Icons