diff zipfiles/zipfile32.py @ 183:8196d2c0d6f8

Updated zipfiles for Python 3.2.1
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 14 Jul 2011 18:52:18 +0300
parents 45d4a9dc707b
children
line wrap: on
line diff
--- a/zipfiles/zipfile32.py	Wed Jun 29 01:26:33 2011 +0300
+++ b/zipfiles/zipfile32.py	Thu Jul 14 18:52:18 2011 +0300
@@ -253,16 +253,14 @@
         # found the magic number; attempt to unpack and interpret
         recData = data[start:start+sizeEndCentDir]
         endrec = list(struct.unpack(structEndArchive, recData))
-        comment = data[start+sizeEndCentDir:]
-        # check that comment length is correct
-        if endrec[_ECD_COMMENT_SIZE] == len(comment):
-            # Append the archive comment and start offset
-            endrec.append(comment)
-            endrec.append(maxCommentStart + start)
+        commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file
+        comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize]
+        endrec.append(comment)
+        endrec.append(maxCommentStart + start)
 
-            # Try to read the "Zip64 end of central directory" structure
-            return _EndRecData64(fpin, maxCommentStart + start - filesize,
-                                 endrec)
+        # Try to read the "Zip64 end of central directory" structure
+        return _EndRecData64(fpin, maxCommentStart + start - filesize,
+                             endrec)
 
     # Unable to find a valid end of central directory structure
     return