Skip to content
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

Fix resource leak in WheelFile.open() #338

Merged
merged 2 commits into from Mar 24, 2020
Merged

Fix resource leak in WheelFile.open() #338

merged 2 commits into from Mar 24, 2020

Conversation

jdufresne
Copy link
Contributor

In WheelFile.open(), if the hash does not exist, avoid opening the file
before raising the exception. Previously would leak the open file
resource which could result in a ResourceWarning when Python warnings
are enabled:

ResourceWarning: unclosed file <_io.FileIO name='…/test_testzip_missing_hash0/test-1.0-py2.py3-none-any.whl' mode='rb' closefd=True>

Python warnings are now enabled during tests to help catch these
earlier.

@agronholm
Copy link
Contributor

I will merge this if you rebase the code against latest master.

jdufresne and others added 2 commits March 24, 2020 06:32
In WheelFile.open(), if the hash does not exist, avoid opening the file
before raising the exception. Previously would leak the open file
resource which could result in a ResourceWarning when Python warnings
are enabled:

    ResourceWarning: unclosed file <_io.FileIO name='…/test_testzip_missing_hash0/test-1.0-py2.py3-none-any.whl' mode='rb' closefd=True>

Python warnings are now enabled during tests to help catch these
earlier.
@jdufresne
Copy link
Contributor Author

Thanks. Rebased.

@agronholm agronholm merged commit ed3ec04 into pypa:master Mar 24, 2020
@agronholm
Copy link
Contributor

Thanks!

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.

None yet

3 participants