From a0f51493ca8ce7e90169a41d96d037ef413b659f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 22 Jan 2026 00:23:58 +1100 Subject: [PATCH] Refer to lazy importing, as lazy loading of images is separate --- src/PIL/Image.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index dfd64ef19..88f79a792 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -323,7 +323,7 @@ def getmodebands(mode: str) -> int: _initialized = 0 -# Mapping from file extension to plugin module name for lazy loading +# Mapping from file extension to plugin module name for lazy importing _EXTENSION_PLUGIN: dict[str, str] = { # Common formats (preinit) ".bmp": "BmpImagePlugin", @@ -402,8 +402,8 @@ _EXTENSION_PLUGIN: dict[str, str] = { } -def _load_plugin_for_extension(ext: str | bytes) -> bool: - """Load only the plugin needed for a specific file extension.""" +def _import_plugin_for_extension(ext: str | bytes) -> bool: + """Import only the plugin needed for a specific file extension.""" if isinstance(ext, bytes): ext = ext.decode() if ext in EXTENSION: @@ -2634,8 +2634,8 @@ class Image: filename_ext = os.path.splitext(filename)[1].lower() ext = filename_ext.decode() if isinstance(filename_ext, bytes) else filename_ext - # Try loading only the plugin for this extension first - if not _load_plugin_for_extension(ext): + # Try importing only the plugin for this extension first + if not _import_plugin_for_extension(ext): preinit() if not format: @@ -3625,7 +3625,7 @@ def open( # Try to load just the plugin needed for this file extension # before falling back to preinit() which loads common plugins ext = os.path.splitext(filename)[1] if filename else "" - if not (ext and _load_plugin_for_extension(ext)): + if not (ext and _import_plugin_for_extension(ext)): preinit() warning_messages: list[str] = []