Index: Lib/zipfile.py =================================================================== --- Lib/zipfile.py (revision 84038) +++ Lib/zipfile.py (working copy) @@ -825,7 +825,9 @@ file=file) def testzip(self): - """Read all the files and check the CRC.""" + """Read all the files and check the CRC. Return None if all files + could be read successfully, or the name of the offending file + otherwise.""" chunk_size = 2 ** 20 for zinfo in self.filelist: try: Index: Lib/test/test_zipfile64.py =================================================================== --- Lib/test/test_zipfile64.py (revision 84038) +++ Lib/test/test_zipfile64.py (working copy) @@ -60,6 +60,7 @@ ' zipTest still writing %d of %d, be patient...' % (num, filecount)), file=sys.__stdout__) sys.__stdout__.flush() + zipfp.close() # Read the ZIP archive @@ -73,6 +74,10 @@ ' zipTest still reading %d of %d, be patient...' % (num, filecount)), file=sys.__stdout__) sys.__stdout__.flush() + + # Check that testzip thinks the archive is valid + self.assertIsNone(zipfp.testzip()) + zipfp.close() def testStored(self): @@ -113,6 +118,25 @@ self.assertEqual(content, "%d" % (i**3 % 57)) zipf.close() + def testziptest(self): + # check that testzip can be used on archives containing very + # large files (about 1GB) + datablock = ''.join([chr(x) for x in range(1,256)]) + datablock *= 4096 + f = open(TESTFN2,'w') + for i in range(1024): + f.write(datablock) + f.close() + + zipf = zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_DEFLATED, + allowZip64=True) + zipf.write(TESTFN2) + zipf.close() + + zipf2 = zipfile.ZipFile(TESTFN, mode="r") + self.assertIsNone(zipf2.testzip()) + zipf.close() + def tearDown(self): support.unlink(TESTFN) support.unlink(TESTFN2) Index: Lib/test/test_zipfile.py =================================================================== --- Lib/test/test_zipfile.py (revision 84038) +++ Lib/test/test_zipfile.py (working copy) @@ -97,8 +97,9 @@ self.assertEqual(info.filename, nm) self.assertEqual(info.file_size, len(self.data)) - # Check that testzip doesn't raise an exception - zipfp.testzip() + # Check that testzip thinks the archive is ok + # (it returns None if all contents could be read properly) + self.assertIsNone(zipfp.testzip()) def test_stored(self): for f in (TESTFN2, TemporaryFile(), io.BytesIO()):