Merge pull request #4413 from radarhere/python3

Changed example plugin to work in Python 3
This commit is contained in:
Hugo van Kemenade 2020-02-09 09:05:33 +02:00 committed by GitHub
commit c56f5bafc0

View File

@ -52,7 +52,6 @@ true color.
**SpamImagePlugin.py**:: **SpamImagePlugin.py**::
from PIL import Image, ImageFile from PIL import Image, ImageFile
import string
class SpamImageFile(ImageFile.ImageFile): class SpamImageFile(ImageFile.ImageFile):
@ -63,10 +62,10 @@ true color.
# check header # check header
header = self.fp.read(128) header = self.fp.read(128)
if header[:4] != "SPAM": if header[:4] != b"SPAM":
raise SyntaxError, "not a SPAM file" raise SyntaxError("not a SPAM file")
header = string.split(header) header = header.split()
# size in pixels (width, height) # size in pixels (width, height)
self._size = int(header[1]), int(header[2]) self._size = int(header[1]), int(header[2])
@ -80,7 +79,7 @@ true color.
elif bits == 24: elif bits == 24:
self.mode = "RGB" self.mode = "RGB"
else: else:
raise SyntaxError, "unknown number of bits" raise SyntaxError("unknown number of bits")
# data descriptor # data descriptor
self.tile = [ self.tile = [