summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/readers.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-10-25 18:21:46 (GMT)
committerGitHub <noreply@github.com>2020-10-25 18:21:46 (GMT)
commitdf8d4c83a6e1727e766191896aeabde886979587 (patch)
treea286f28927d1cd736787880784d2c1af908b45b8 /Lib/importlib/readers.py
parentc32f2976b8f4034724c3270397aa16f38daf470f (diff)
downloadcpython-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.py6
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)