Repository navigation
fix(types): close local image files read by ImageRef.pil_image - #1097
Open
Yogeshwar-CM wants to merge 1 commit into
Open
Yogeshwar-CM wants to merge 1 commit into
Yogeshwar-CM wants to merge 1 commit into
Conversation
Contributor
|
✅ DCO Check Passed Thanks @Yogeshwar-CM, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Contributor
AI triage (advisory)Checked commit Warning The AI analysis did not finish. Only the deterministic checks are shown. CI safety: not assessed. The |
Fixes docling-project#1096 Signed-off-by: Yogeshwar CM <84910252+Yogeshwar-CM@users.noreply.github.com>
Yogeshwar-CM
force-pushed
the
fix/close-local-image-file
branch
from
November 28, 2026 14:22
e6420f5 to
4c47b54
Compare
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1096
Summary
ImageRef.pil_imagekept thePILImage.open(local_path)result, so a local image file stayed open until Pillow loaded the pixels, or for the life of the image for multi-frame files. It now reads the image the same way_load_local_imagealready does: open it in awithblock and keep a copy, so the file is closed beforepil_imagereturns.The
data:URI branch is unchanged, because it reads from an in-memoryBytesIO.Tests
test_file_uri_image_does_not_keep_file_open: reads afile://image, drops the references, and asserts noResourceWarning. It fails without the change and passes with it.test_file_uri_allowed_with_env_varnow also passes underpytest -W error.-W erroris an unrelated socketResourceWarningintest_visualization.py::test_doc_visualization, which also fails on main.ruff checkandruff format --checkpass on the changed files.