Skip to content

gh-137589: Close file objects in test_zipfile/test_core.py - #138099

Closed
Yzi-Li wants to merge 2 commits into
python:mainfrom
Yzi-Li:close-files-in-test-core
Closed

Yzi-Li wants to merge 2 commits into
python:mainfrom
Yzi-Li:close-files-in-test-core

Conversation

@Yzi-Li

@Yzi-Li Yzi-Li commented Aug 24, 2025 •

Copy link
Copy Markdown
Contributor

@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Aug 24, 2025
@Yzi-Li
Yzi-Li marked this pull request as ready for review August 24, 2025 04:23
@StanFromIreland

Copy link
Copy Markdown
Member

Hello, thanks however a PR was already opened for both files yesterday, #138080.

@Yzi-Li

Yzi-Li commented Aug 24, 2025

Copy link
Copy Markdown
Contributor Author

But there are still some file objects that have not been closed in that PR.

@StanFromIreland

StanFromIreland commented Aug 24, 2025 •

Copy link
Copy Markdown
Member

You are closing files that should not be opened, if they are opened the test is broken anyway as the error (with assertRaises(error):) is not raised. For some other cases, when a zipfile is opened in a width block, e.g. with zipfile.ZipFile(...) as zf: it is automatically closed, you can think of it as there being an automatic finally: zf.close().

@Yzi-Li

Yzi-Li commented Aug 24, 2025

Copy link
Copy Markdown
Contributor Author

I see, thanks.

@Yzi-Li
Yzi-Li deleted the close-files-in-test-core branch October 12, 2025 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants