From 39288f0fb0755b8ef9bbc4867bda6a19e91287fd Mon Sep 17 00:00:00 2001 From: Piolie Date: Sun, 31 Jan 2021 00:51:39 -0300 Subject: [PATCH] Create `maxval` variable --- src/PIL/PpmImagePlugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PIL/PpmImagePlugin.py b/src/PIL/PpmImagePlugin.py index 5ff98e346..93ce3a4d2 100644 --- a/src/PIL/PpmImagePlugin.py +++ b/src/PIL/PpmImagePlugin.py @@ -125,7 +125,8 @@ class PpmImageFile(ImageFile.ImageFile): if mode == "1": break elif ix == 2: # token is maxval - if token > 255: + maxval = token + if maxval > 255: if not mode == "L": raise ValueError(f"Too many colors for band: {token}") if token < 2 ** 16: