diff --git a/src/PIL/BlpImagePlugin.py b/src/PIL/BlpImagePlugin.py index c229cc9ce..355795cb9 100644 --- a/src/PIL/BlpImagePlugin.py +++ b/src/PIL/BlpImagePlugin.py @@ -40,6 +40,11 @@ from typing import IO from . import Image, ImageFile +branches = { + "1": False, + "2": False, + } + class Format(IntEnum): JPEG = 0 @@ -276,22 +281,20 @@ class BlpImageFile(ImageFile.ImageFile): class _BLPBaseDecoder(ImageFile.PyDecoder): - + branches = { + "1": False, + "2": False, + } _pulls_fd = True def decode(self, buffer: bytes) -> tuple[int, int]: - branches = { - "1": False, - "2": False, - } - try: - branches["1"] = True; + branches["1"] = True self._read_blp_header() self._load() except struct.error as e: - branches["2"] = True; + branches["2"] = True msg = "Truncated BLP file" raise OSError(msg) from e return -1, 0 diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py index f90faf397..223a0df45 100644 --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -48,11 +48,11 @@ def read_32t(fobj, start_length, size): fobj.seek(start) sig = fobj.read(4) if sig != b"\x00\x00\x00\x00": - branches["1"] = True; + branches["1"] = True msg = "Unknown signature, expecting 0x00000000" raise SyntaxError(msg) else: - branches["2"] = True; + branches["2"] = True return read_32(fobj, (start + 4, length - 4), size)