Skip to content

Commit c56f5ba

Browse files
authored
Merge pull request #4413 from radarhere/python3
Changed example plugin to work in Python 3
2 parents 6a8220c + 8e7010d commit c56f5ba

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

docs/handbook/writing-your-own-file-decoder.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ true color.
5252
**SpamImagePlugin.py**::
5353

5454
from PIL import Image, ImageFile
55-
import string
5655

5756
class SpamImageFile(ImageFile.ImageFile):
5857

@@ -63,10 +62,10 @@ true color.
6362

6463
# check header
6564
header = self.fp.read(128)
66-
if header[:4] != "SPAM":
67-
raise SyntaxError, "not a SPAM file"
65+
if header[:4] != b"SPAM":
66+
raise SyntaxError("not a SPAM file")
6867

69-
header = string.split(header)
68+
header = header.split()
7069

7170
# size in pixels (width, height)
7271
self._size = int(header[1]), int(header[2])
@@ -80,7 +79,7 @@ true color.
8079
elif bits == 24:
8180
self.mode = "RGB"
8281
else:
83-
raise SyntaxError, "unknown number of bits"
82+
raise SyntaxError("unknown number of bits")
8483

8584
# data descriptor
8685
self.tile = [

0 commit comments

Comments
 (0)