Decode bytes before passing to f-string

This commit is contained in:
Andrew Murray 2022-04-24 15:42:45 +10:00
parent 25b69f6578
commit 5867e0bbac
2 changed files with 2 additions and 2 deletions

View File

@ -123,7 +123,7 @@ def test_token_too_long(tmp_path):
with Image.open(path):
pass
assert str(e.value) == "Token too long in file header: b'01234567890'"
assert str(e.value) == "Token too long in file header: 01234567890"
def test_truncated_file(tmp_path):

View File

@ -83,7 +83,7 @@ class PpmImageFile(ImageFile.ImageFile):
# Token was not even 1 byte
raise ValueError("Reached EOF while reading header")
elif len(token) > 10:
raise ValueError(f"Token too long in file header: {token}")
raise ValueError(f"Token too long in file header: {token.decode()}")
return token
def _open(self):