This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pysquared
Recipients
Date 2007-08-15.22:37:50
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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()
History
Date User Action Args
2007-08-23 15:59:41adminlinkissue1775025 messages
2007-08-23 15:59:41admincreate