From 5867e0bbacb17a192b8c44a22aaca6be29dd2c39 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 24 Apr 2022 15:42:45 +1000 Subject: [PATCH] Decode bytes before passing to f-string --- Tests/test_file_ppm.py | 2 +- src/PIL/PpmImagePlugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 2c965318b..0f60d28ef 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -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): diff --git a/src/PIL/PpmImagePlugin.py b/src/PIL/PpmImagePlugin.py index b760e228d..14bf94d10 100644 --- a/src/PIL/PpmImagePlugin.py +++ b/src/PIL/PpmImagePlugin.py @@ -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):