Message53038
Allow open() 'name' parameter to be a ZipInfo object, which allows opening archive members with duplicate filenames. Also allow read() 'name' parameter to be a ZipInfo object, as it calls open() directly.
I got sent a zip file which had duplicate names in it, and the only way I could see to extract it using zipfile.py was to apply this patch.
The infolist() and namelist() methods will return information for duplicate filenames, but the open() method takes only a name.
This patch also updated the docs for zipfile.py.
Python 2.1 -> 2.5 zipfile.py module does not have an open() method, but it would be trivial to backport this patch to enhance the read() method.
# Test:
# write() optionally warns, but still allows,
# creating duplicate file names:
import zipfile
zf = zipfile.ZipFile('dupzip.zip', 'w')
zf.debug = 1
zf.writestr('dupname', 'Hello')
zf.writestr('dupname', 'World')
zf.close()
# Print 'Hello' 'World'
zfr = zipfile.ZipFile('dupzip.zip', 'r')
for inf in zfr.infolist():
print repr(zfr.read(inf))
zfr.close()
|
|
Date |
User |
Action |
Args |
2007-08-23 15:59:41 | admin | link | issue1775025 messages |
2007-08-23 15:59:41 | admin | create | |
|