[Patches] [ python-Patches-1775025 ] zipfile: Allow reading duplicate filenames

SourceForge.net noreply at sourceforge.net
Thu Aug 16 00:37:50 CEST 2007


Patches item #1775025, was opened at 2007-08-15 23:37
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1775025&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Graham Horler (grahamh)
Assigned to: Nobody/Anonymous (nobody)
Summary: zipfile: Allow reading duplicate filenames

Initial Comment:
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()


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1775025&group_id=5470


More information about the Patches mailing list