diff options
author | Georg Brandl <georg@python.org> | 2008-05-20 08:25:48 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-20 08:25:48 (GMT) |
commit | 112aa5032985925608844d7421e12703afd6ce41 (patch) | |
tree | b7e26da27c90471192c42afea278b8b9f59ef9f3 /Lib/zipfile.py | |
parent | 4dd019fde36b53b30e69a2ce9cee3f2f9f25c2a6 (diff) | |
download | cpython-112aa5032985925608844d7421e12703afd6ce41.zip cpython-112aa5032985925608844d7421e12703afd6ce41.tar.gz cpython-112aa5032985925608844d7421e12703afd6ce41.tar.bz2 |
Patch #1775025: allow opening zipfile members via ZipInfo instances.
Patch by Graham Horler.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 33fcfb1..b812a82 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -776,10 +776,13 @@ class ZipFile: else: zef_file = open(self.filename, 'rb') - # Get info object for name - zinfo = self.getinfo(name) - - filepos = zef_file.tell() + # Make sure we have an info object + if isinstance(name, ZipInfo): + # 'name' is already an info object + zinfo = name + else: + # Get info object for name + zinfo = self.getinfo(name) zef_file.seek(zinfo.header_offset, 0) @@ -884,7 +887,7 @@ class ZipFile: if upperdirs and not os.path.exists(upperdirs): os.makedirs(upperdirs) - source = self.open(member.filename, pwd=pwd) + source = self.open(member, pwd=pwd) target = file(targetpath, "wb") shutil.copyfileobj(source, target) source.close() |