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

bpo-41490: path and contents to aggressively close handles #22915

Merged
merged 4 commits into from
Oct 25, 2020
Merged

bpo-41490: path and contents to aggressively close handles #22915

merged 4 commits into from
Oct 25, 2020

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Oct 23, 2020

As found in importlib_resources 3.1.1.

https://bugs.python.org/issue41490

Automerge-Triggered-By: GH:jaraco

@jaraco
Copy link
Member Author

jaraco commented Oct 23, 2020

I need to investigate why the zip test data changed.

@jaraco
Copy link
Member Author

jaraco commented Oct 23, 2020

I see I refreshed those zips in python/importlib_resources@9342877, and this is the first sync since.

@jaraco
Copy link
Member Author

jaraco commented Oct 23, 2020

Oh, that's interesting. test_contents_does_not_keep_open still fails here where it doesn't on importlib_resources.

@jaraco jaraco changed the title bpo-41490: path method to aggressively close handles WIP: bpo-41490: path method to aggressively close handles Oct 23, 2020
@jaraco
Copy link
Member Author

jaraco commented Oct 23, 2020

I don't want to apply the fix at ZipReader because I want ZipReader.contents to evaluate lazily. The compatibility only needs to be applied to contents().

…eagerly converted to a list if it's not already a sequence.
@jaraco jaraco changed the title WIP: bpo-41490: path method to aggressively close handles bpo-41490: path method to aggressively close handles Oct 23, 2020
@jaraco jaraco changed the title bpo-41490: path method to aggressively close handles bpo-41490: path and contents to aggressively close handles Oct 23, 2020
self.zip_path.unlink()
del c

@unittest.skip("Desired but not supported.")
Copy link
Member Author

Choose a reason for hiding this comment

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

I should call out that this test is being skipped because it proved too difficult to support.

Copy link
Member

Choose a reason for hiding this comment

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

This one is but the following one is not?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I found a way to support this use-case, but only by not supporting the latter... and the latter was more important to certifi.

@jaraco
Copy link
Member Author

jaraco commented Oct 25, 2020

I'd like to proceed with merging this change. We can iterate or revert later as needed.

@jaraco jaraco merged commit df8d4c8 into python:master Oct 25, 2020
@bedevere-bot
Copy link

@jaraco: Please replace # with GH- in the commit message next time. Thanks!

@jaraco jaraco deleted the bugfix/bpo-41490 branch October 25, 2020 18:21
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…ython#22915)

* bpo-41490: ``path`` method to aggressively close handles

* Add blurb

* In ZipReader.contents, eagerly evaluate the contents to release references to the zipfile.

* Instead use _ensure_sequence to ensure any iterable from a reader is eagerly converted to a list if it's not already a sequence.
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.

4 participants