Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ def getmodebands(mode: str) -> int:

def _import_plugin_for_extension(ext: str | bytes) -> bool:
"""Import only the plugin needed for a specific file extension."""
if not ext:
return False

if isinstance(ext, bytes):
ext = ext.decode()
ext = ext.lower()
Expand Down Expand Up @@ -3633,7 +3636,7 @@ def open(
# Try to import just the plugin needed for this file extension
# before falling back to preinit() which imports common plugins
ext = os.path.splitext(filename)[1] if filename else ""
if not (ext and _import_plugin_for_extension(ext)):
if not _import_plugin_for_extension(ext):
preinit()

warning_messages: list[str] = []
Expand Down
Loading