diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-10-25 18:21:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-25 18:21:46 (GMT) |
commit | df8d4c83a6e1727e766191896aeabde886979587 (patch) | |
tree | a286f28927d1cd736787880784d2c1af908b45b8 /Lib/importlib/readers.py | |
parent | c32f2976b8f4034724c3270397aa16f38daf470f (diff) | |
download | cpython-df8d4c83a6e1727e766191896aeabde886979587.zip cpython-df8d4c83a6e1727e766191896aeabde886979587.tar.gz cpython-df8d4c83a6e1727e766191896aeabde886979587.tar.bz2 |
bpo-41490: ``path`` and ``contents`` to aggressively close handles (#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.
Diffstat (limited to 'Lib/importlib/readers.py')
-rw-r--r-- | Lib/importlib/readers.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/importlib/readers.py b/Lib/importlib/readers.py index 6331e4d..74a63e4 100644 --- a/Lib/importlib/readers.py +++ b/Lib/importlib/readers.py @@ -22,8 +22,8 @@ class FileReader(abc.TraversableResources): class ZipReader(abc.TraversableResources): def __init__(self, loader, module): _, _, name = module.rpartition('.') - prefix = loader.prefix.replace('\\', '/') + name + '/' - self.path = zipfile.Path(loader.archive, prefix) + self.prefix = loader.prefix.replace('\\', '/') + name + '/' + self.archive = loader.archive def open_resource(self, resource): try: @@ -38,4 +38,4 @@ class ZipReader(abc.TraversableResources): return target.is_file() and target.exists() def files(self): - return self.path + return zipfile.Path(self.archive, self.prefix) |