diff --git a/src/PIL/ImageStat.py b/src/PIL/ImageStat.py index 2cb841eef..8bc504526 100644 --- a/src/PIL/ImageStat.py +++ b/src/PIL/ImageStat.py @@ -52,9 +52,9 @@ class Stat: """ if isinstance(image_or_list, Image.Image): self.h = image_or_list.histogram(mask) - else: + elif isinstance(image_or_list, list): self.h = image_or_list - if not isinstance(self.h, list): + else: msg = "first argument must be image or list" # type: ignore[unreachable] raise TypeError(msg) self.bands = list(range(len(self.h) // 256))