diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index fdc5a46ca..a7f4c1b5f 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -98,7 +98,8 @@ class ImagePalette(object): except KeyError: # allocate new color slot if isinstance(self.palette, bytes): - self.palette = [int(x) for x in self.palette] + self.palette = [(ord(x) if str is bytes else int(x)) + for x in self.palette] index = len(self.colors) if index >= 256: raise ValueError("cannot allocate more than 256 colors") diff --git a/Tests/images/chi.gif b/Tests/images/chi.gif new file mode 100644 index 000000000..d217f8b5e Binary files /dev/null and b/Tests/images/chi.gif differ diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 947e35971..b86ae7768 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -52,6 +52,13 @@ class TestImageDraw(PillowTestCase): self.assertRaises(Exception, lambda: draw.setink(0)) self.assertRaises(Exception, lambda: draw.setfill(0)) + def test_valueerror(self): + im = Image.open("Tests/images/chi.gif") + + draw = ImageDraw.Draw(im) + draw.line(((0, 0)), fill=(0, 0, 0)) + del draw + def test_mode_mismatch(self): im = hopper("RGB").copy()