mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +03:00
Fixed BytesWarning
This commit is contained in:
parent
7b6f4c6ef5
commit
967034356a
|
@ -208,7 +208,9 @@ class PpmPlainDecoder(ImageFile.PyDecoder):
|
||||||
tokens = b"".join(block.split())
|
tokens = b"".join(block.split())
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
if token not in (48, 49):
|
if token not in (48, 49):
|
||||||
raise ValueError(f"Invalid token for this mode: {bytes([token])}")
|
raise ValueError(
|
||||||
|
b"Invalid token for this mode: %s" % bytes([token])
|
||||||
|
)
|
||||||
data = (data + tokens)[:total_bytes]
|
data = (data + tokens)[:total_bytes]
|
||||||
invert = bytes.maketrans(b"01", b"\xFF\x00")
|
invert = bytes.maketrans(b"01", b"\xFF\x00")
|
||||||
return data.translate(invert)
|
return data.translate(invert)
|
||||||
|
@ -242,13 +244,13 @@ class PpmPlainDecoder(ImageFile.PyDecoder):
|
||||||
half_token = tokens.pop() # save half token for later
|
half_token = tokens.pop() # save half token for later
|
||||||
if len(half_token) > max_len: # prevent buildup of half_token
|
if len(half_token) > max_len: # prevent buildup of half_token
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Token too long found in data: {half_token[:max_len + 1]}"
|
b"Token too long found in data: %s" % half_token[: max_len + 1]
|
||||||
)
|
)
|
||||||
|
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
if len(token) > max_len:
|
if len(token) > max_len:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Token too long found in data: {token[:max_len + 1]}"
|
b"Token too long found in data: %s" % token[: max_len + 1]
|
||||||
)
|
)
|
||||||
value = int(token)
|
value = int(token)
|
||||||
if value > maxval:
|
if value > maxval:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user