From 4f31cd7a31a6be2ac38773bab6f0a5451480f5b8 Mon Sep 17 00:00:00 2001 From: Deekshu Kare Date: Fri, 21 Jun 2024 23:16:51 +0200 Subject: [PATCH] imagefile flags added --- conftest.py | 2 ++ src/PIL/ImageFile.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/conftest.py b/conftest.py index 260330c28..8d1320209 100644 --- a/conftest.py +++ b/conftest.py @@ -6,6 +6,7 @@ from PIL import Image from PIL import PdfParser from PIL import ImageCms from PIL import McIdasImagePlugin +from PIL import ImageFile pytest_plugins = ["Tests.helper"] @@ -16,6 +17,7 @@ def calculate_coverage(test_name): "branches2": PdfParser.XrefTable.branches, "branches3": ImageCms.ImageCmsProfile.branches, "branches4": McIdasImagePlugin.McIdasImageFile.branches, + "branches5": ImageFile.PyEncoder.branches, # Add more } diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index 3b6100e13..08c746efe 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -39,6 +39,11 @@ from . import Image from ._deprecate import deprecate from ._util import is_path +branches = { + "1": False, + "2": False, +} + MAXBLOCK = 65536 SAFEBLOCK = 1024 * 1024 @@ -750,6 +755,11 @@ class PyDecoder(PyCodec): class PyEncoder(PyCodec): + + branches = { + "1": False, + "2": False, + } """ Python implementation of a format encoder. Override this class and add the decoding logic in the :meth:`encode` method. @@ -801,7 +811,9 @@ class PyEncoder(PyCodec): """ errcode = 0 while errcode == 0: + PyEncoder.branches["1"] = True status, errcode, buf = self.encode(bufsize) if status > 0: + PyEncoder.branches["2"] = True fh.write(buf[status:]) return errcode