Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #9047

The following code didn't consider the possibility of an empty filename being passed in by the user, and tries to treat it as a file handle instead.

Pillow/src/PIL/Image.py

Lines 3510 to 3518 in 2b39f75

filename: str | bytes = ""
if is_path(fp):
filename = os.fspath(fp)
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
else:
fp = cast(IO[bytes], fp)

This fixes that.

@hugovk hugovk merged commit 84855d1 into python-pillow:main Jun 30, 2025
57 checks passed
@radarhere radarhere deleted the empty_path branch June 30, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Image.open(str)

2 participants