From 74f0bc7dfe45621b70b04d7aa4ad0759607ad717 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 15 Oct 2026 20:35:01 +1100 Subject: [PATCH 1/2] Do not lazily import optional modules --- src/PIL/FpxImagePlugin.py | 2 +- src/PIL/MicImagePlugin.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index 16eb3a9d3b7..6da46c17bee 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -16,7 +16,7 @@ # from __future__ import annotations -__lazy_modules__ = {"PIL._binary", "olefile"} +__lazy_modules__ = {"PIL._binary"} import olefile diff --git a/src/PIL/MicImagePlugin.py b/src/PIL/MicImagePlugin.py index 76a2c9b4975..9d92297115b 100644 --- a/src/PIL/MicImagePlugin.py +++ b/src/PIL/MicImagePlugin.py @@ -17,8 +17,6 @@ # from __future__ import annotations -__lazy_modules__ = {"olefile"} - import olefile from . import Image, TiffImagePlugin From fb2c298ac69d2204d56030b7a38e118381213a06 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 15 Oct 2026 21:00:12 +1100 Subject: [PATCH 2/2] Move import inside test --- Tests/test_file_mic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_mic.py b/Tests/test_file_mic.py index 4cd376188f3..9424bcf0893 100644 --- a/Tests/test_file_mic.py +++ b/Tests/test_file_mic.py @@ -2,7 +2,6 @@ from io import BytesIO -import olefile import pytest from PIL import Image, ImagePalette @@ -101,6 +100,8 @@ def test_seek_size_change() -> None: def test_seek_decompression_bomb(tmp_path: Path) -> None: + import olefile + with Image.open(TEST_FILE) as im: assert isinstance(im, MicImagePlugin.MicImageFile) im._n_frames = 2