Skip to content

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

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

Closed
wants to merge 2 commits into from

Conversation

Yzi-Li
Copy link
Contributor

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

@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
Member

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

@Yzi-Li
Copy link
Contributor Author

Yzi-Li commented Aug 24, 2025

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

@StanFromIreland
Copy link
Member

StanFromIreland commented Aug 24, 2025

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
Copy link
Contributor Author

Yzi-Li commented Aug 24, 2025

I see, thanks.

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