mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-13 01:05:48 +03:00
Do not add palette entries when reading other lines
This commit is contained in:
parent
9c8c7a0a4e
commit
d76d45a28e
|
@ -32,4 +32,4 @@ def test_get_palette() -> None:
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert mode == "RGB"
|
assert mode == "RGB"
|
||||||
assert len(palette) / 3 == 11
|
assert len(palette) / 3 == 8
|
||||||
|
|
|
@ -32,14 +32,13 @@ class GimpPaletteFile:
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
palette: list[int] = []
|
palette: list[int] = []
|
||||||
for i in range(256):
|
for _ in range(256):
|
||||||
s = fp.readline()
|
s = fp.readline()
|
||||||
if not s:
|
if not s:
|
||||||
break
|
break
|
||||||
|
|
||||||
# skip fields and comment lines
|
# skip fields and comment lines
|
||||||
if re.match(rb"\w+:|#", s):
|
if re.match(rb"\w+:|#", s):
|
||||||
palette.append(o8(i) * 3)
|
|
||||||
continue
|
continue
|
||||||
if len(s) > 100:
|
if len(s) > 100:
|
||||||
msg = "bad palette file"
|
msg = "bad palette file"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user