Skip to content

Conversation

@radarhere
Copy link
Member

Fixes an unclosed file warning from https://github.com/python-pillow/Pillow/actions/runs/19457141721/job/55673162157#step:11:5270

Tests/test_imagefont.py::test_load_invalid_file
/Users/runner/work/Pillow/Pillow/Tests/test_imagefont.py:497: ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/1_trns.png'>
with pytest.raises(SyntaxError, match="Not a PILfont file"):

by adding image.close() when exceptions are raised in ImageFont._load_pilfont_data(). This method is only called internally after creating the ImageFont instance, so there's no need for the image afterwards.

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.

1 participant