Skip to content

Commit d568c8d

Browse files
authored
Check ext is not empty during save (#145)
2 parents 2b186fc + d08d7ee commit d568c8d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/PIL/Image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ def getmodebands(mode: str) -> int:
404404

405405
def _import_plugin_for_extension(ext: str | bytes) -> bool:
406406
"""Import only the plugin needed for a specific file extension."""
407+
if not ext:
408+
return False
409+
407410
if isinstance(ext, bytes):
408411
ext = ext.decode()
409412
ext = ext.lower()
@@ -3633,7 +3636,7 @@ def open(
36333636
# Try to import just the plugin needed for this file extension
36343637
# before falling back to preinit() which imports common plugins
36353638
ext = os.path.splitext(filename)[1] if filename else ""
3636-
if not (ext and _import_plugin_for_extension(ext)):
3639+
if not _import_plugin_for_extension(ext):
36373640
preinit()
36383641

36393642
warning_messages: list[str] = []

0 commit comments

Comments
 (0)