From 92e57889d0ce12c81d4cd96f1cfe023fd85cdef6 Mon Sep 17 00:00:00 2001 From: gdesmar <75089569+gdesmar@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:46:58 +0000 Subject: [PATCH] Validate self.palette in has_transparency_data() --- src/PIL/Image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index a770488b7..f980bb241 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1561,7 +1561,7 @@ class Image: """ return ( self.mode in ("LA", "La", "PA", "RGBA", "RGBa") - or (self.mode == "P" and self.palette.mode.endswith("A")) + or (self.mode == "P" and self.palette and self.palette.mode.endswith("A")) or "transparency" in self.info )