Index: Lib/zipfile.py =================================================================== --- Lib/zipfile.py (revision 87413) +++ Lib/zipfile.py (working copy) @@ -256,6 +256,13 @@ # Try to read the "Zip64 end of central directory" structure return _EndRecData64(fpin, maxCommentStart + start - filesize, endrec) + else: + # be robust to non-comment extaneous data after endrec + # by making it a comment so that nothing is ever lost + endrec[_ECD_COMMENT_SIZE] = len(comment) + endrec.append(comment) + endrec.append(maxCommentStart + start) + return endrec # Unable to find a valid end of central directory structure return Index: Lib/test/test_zipfile.py =================================================================== --- Lib/test/test_zipfile.py (revision 87413) +++ Lib/test/test_zipfile.py (working copy) @@ -723,6 +723,10 @@ b'\x01\x003\x00\x00\x003\x00\x00\x00\x00\x00'), } + def test_ignores_comments(self): + with zipfile.ZipFile("README.zip") as zf: + self.assertIsInstance(zf, zipfile.ZipFile) + def test_unicode_filenames(self): with zipfile.ZipFile(TESTFN, "w") as zf: zf.writestr("foo.txt", "Test for unicode filename")