Skip to content

Commit 541084f

Browse files
author
bstorm
committed
Merge remote-tracking branch 'origin/master' into ppm
2 parents 456d9ca + ce7646e commit 541084f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

adafruit_imageload/pnm/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ def load(f, header, *, bitmap=None, palette=None):
5454

5555
next_byte = f.read(1)
5656
if next_byte == b"#":
57-
if next_byte != b"\n":
58-
continue
59-
dec_re = re.compile(r"\d")
60-
if dec_re.match(next_byte):
57+
while True:
58+
f.read(1)
59+
if not next_byte:
60+
raise RuntimeError("Unsupported image format")
61+
if next_byte != b"\n":
62+
break
63+
if next_byte.isdigit():
6164
pnm_header.append(next_byte)
6265
continue
6366

0 commit comments

Comments
 (0)