Fixed unclosed file warning by radarhere · Pull Request #8847 · 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
Mar 30, 2025Merged
Fixed unclosed file warning#8847
hugovk merged 1 commit intopython-pillow:mainfrom
Fixed unclosed file warning#8847
hugovk merged 1 commit intopython-pillow:mainfrom
Conversation
Copy link Copy Markdown
Member
radarhere
commented
Mar 30, 2025
radarhere
commented
Lines 232 to 236 in 60b5131
| def test_unknown_extension(self, tmp_path: Path) -> None: | |
| im = hopper() | |
| temp_file = tmp_path / "temp.unknown" | |
| with pytest.raises(ValueError): | |
| im.save(temp_file) |
raises an unclosed file warning - https://github.com/python-pillow/Pillow/actions/runs/14155530774/job/39654267057?pr=8844#step:6:5623
This is because hopper() is just returning an opened image.
Lines 248 to 257 in 60b5131
| def hopper(mode: str | None = None) -> Image.Image: | |
| # Use caching to reduce reading from disk, but return a copy | |
| # so that the cached image isn't modified by the tests | |
| # (for fast, isolated, repeatable tests). | |
| if mode is None: | |
| # Always return fresh not-yet-loaded version of image. | |
| # Operations on not-yet-loaded images are a separate class of errors | |
| # that we should catch. | |
| return Image.open("Tests/images/hopper.ppm") |
radarhere
added
the
Testing
label
radarhere
deleted the
unclosed_file
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