Skip to content

Commit 204d11d

Browse files
committed
Raise FileNotFoundError when opening an empty path
1 parent 2b39f75 commit 204d11d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Tests/test_image.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def test_set_mode(self) -> None:
160160
with pytest.raises(AttributeError):
161161
im.mode = "P" # type: ignore[misc]
162162

163+
def test_empty_path(self) -> None:
164+
with pytest.raises(FileNotFoundError):
165+
Image.open("")
166+
163167
def test_invalid_image(self) -> None:
164168
im = io.BytesIO(b"")
165169
with pytest.raises(UnidentifiedImageError):

src/PIL/Image.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,8 +3510,6 @@ def open(
35103510
filename: str | bytes = ""
35113511
if is_path(fp):
35123512
filename = os.fspath(fp)
3513-
3514-
if filename:
35153513
fp = builtins.open(filename, "rb")
35163514
exclusive_fp = True
35173515
else:

0 commit comments

Comments
 (0)