Merge pull request #6239 from radarhere/ppm_token

Decode bytes before passing to f-string
This commit is contained in:
Hugo van Kemenade 2022-04-26 09:14:20 +03:00 committed by GitHub
commit 42a81c4173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):