From 2a403860d1271f33c2c7c637bf9cabaab8313078 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 1 Apr 2019 11:30:23 +1100 Subject: [PATCH 1/2] Removed condition that was always true --- src/PIL/GimpPaletteFile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PIL/GimpPaletteFile.py b/src/PIL/GimpPaletteFile.py index 6eef6a2dd..fa7cfc3bc 100644 --- a/src/PIL/GimpPaletteFile.py +++ b/src/PIL/GimpPaletteFile.py @@ -50,8 +50,7 @@ class GimpPaletteFile(object): if len(v) != 3: raise ValueError("bad palette entry") - if 0 <= i <= 255: - self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2]) + self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2]) i += 1 From 7c154f52fa0110bfb53c9c2bb12f5c534f6bc5d8 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 1 Apr 2019 11:32:51 +1100 Subject: [PATCH 2/2] Replaced while with for loop --- src/PIL/GimpPaletteFile.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/PIL/GimpPaletteFile.py b/src/PIL/GimpPaletteFile.py index fa7cfc3bc..0ee899988 100644 --- a/src/PIL/GimpPaletteFile.py +++ b/src/PIL/GimpPaletteFile.py @@ -32,14 +32,12 @@ class GimpPaletteFile(object): if fp.readline()[:12] != b"GIMP Palette": raise SyntaxError("not a GIMP palette file") - i = 0 - - while i <= 255: + for i in range(256): s = fp.readline() - if not s: break + # skip fields and comment lines if re.match(br"\w+:|#", s): continue @@ -52,8 +50,6 @@ class GimpPaletteFile(object): self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2]) - i += 1 - self.palette = b"".join(self.palette) def getpalette(self):