From 1401adaefa31057b64d91641096e1f943d160cea Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Tue, 12 Mar 2013 20:19:08 +0100 Subject: [PATCH 1/2] fix warning for python3 use PyUnicode_FromString instead of PyString_FromString this warning prevented loading _imaging, somehow --- _imaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_imaging.c b/_imaging.c index 0ced4d488..29f1f2352 100644 --- a/_imaging.c +++ b/_imaging.c @@ -932,7 +932,7 @@ _getpalettemode(ImagingObject* self, PyObject* args) return NULL; } - return PyString_FromString(self->image->palette->mode); + return PyUnicode_FromString(self->image->palette->mode); } static inline int From 2d478fe82a2deefabb7b536b6b88441a500c1ef1 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Tue, 12 Mar 2013 21:29:46 +0100 Subject: [PATCH 2/2] fixed check for str with Python 3 --- PIL/Image.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index b79335a13..1e29db198 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -628,10 +628,10 @@ class Image: self.palette.mode = "RGB" self.palette.rawmode = None if "transparency" in self.info: - if isinstance(self.info["transparency"], str): - self.im.putpalettealphas(self.info["transparency"]) - else: + if isinstance(self.info["transparency"], int): self.im.putpalettealpha(self.info["transparency"], 0) + else: + self.im.putpalettealphas(self.info["transparency"]) self.palette.mode = "RGBA" if self.im: