Raise FileNotFoundError when opening an empty path by radarhere · Pull Request #9048 · python-pillow/Pillow
Navigation Menu
{{ message }}
python-pillow / Pillow Public
- Notifications You must be signed in to change notification settings
- Fork 2.4k
Merged
hugovk merged 1 commit intopython-pillow:mainfrom
Jun 30, 2025Merged
Raise FileNotFoundError when opening an empty path#9048
hugovk merged 1 commit intopython-pillow:mainfrom
Raise FileNotFoundError when opening an empty path#9048
hugovk merged 1 commit intopython-pillow:mainfrom
Conversation
Copy link Copy Markdown
Member
radarhere
commented
Jun 30, 2025
radarhere
commented
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.
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.
radarhere
mentioned this pull request
radarhere
deleted the
empty_path
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment