Skip to content

Close TarIO file handle on error #8846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2025
Merged

Conversation

radarhere
Copy link
Member

When testing TarIO errors, the file handle is not closed - https://github.com/python-pillow/Pillow/actions/runs/14155530774/job/39654267057?pr=8844#step:6:5611

Tests/test_file_tar.py::test_unexpected_end
  /Pillow/Tests/test_file_tar.py:38: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/pytest-of-pillow/pytest-0/test_unexpected_end0/temp.tar'>
    with pytest.raises(OSError, match="unexpected end of tar file"):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

Tests/test_file_tar.py::test_cannot_find_subfile
  /Pillow/Tests/test_file_tar.py:44: ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/hopper.tar'>
    with pytest.raises(OSError, match="cannot find subfile"):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

This fixes that.

@hugovk hugovk merged commit f673f3e into python-pillow:main Mar 30, 2025
55 checks passed
@radarhere radarhere deleted the tario branch March 30, 2025 20:22
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.

2 participants