Skip to content

Close file handler#45187

Merged
ydshieh merged 2 commits intomainfrom
close_fp
Apr 10, 2026
Merged

Close file handler#45187
ydshieh merged 2 commits intomainfrom
close_fp

Conversation

@ydshieh
Copy link
Copy Markdown
Collaborator

@ydshieh ydshieh commented Apr 2, 2026

What does this PR do?

Close file handler.

image_data = re.sub("^data:image/.+;base64,", "", url)
image = Image.open(BytesIO(base64.b64decode(image_data)))
file = tempfile.NamedTemporaryFile(suffix=".png", delete=False)
file.close() # close handle immediately after creation
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The report also says we still have file accumulation issue (security), but that part requires a design change.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@ydshieh
Copy link
Copy Markdown
Collaborator Author

ydshieh commented Apr 3, 2026

knock-knock 👀 ??

@ydshieh
Copy link
Copy Markdown
Collaborator Author

ydshieh commented Apr 9, 2026

Anyone here @tarekziade maybe?

@ydshieh
Copy link
Copy Markdown
Collaborator Author

ydshieh commented Apr 10, 2026

Going to merge, as this is somehow important.

@ydshieh ydshieh merged commit c9f1b95 into main Apr 10, 2026
19 checks passed
@ydshieh ydshieh deleted the close_fp branch April 10, 2026 11:31
sirzechs66 pushed a commit to sirzechs66/transformers that referenced this pull request Apr 18, 2026
* fix

* fix

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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