diff -rc Python-2.3b1-orig/Lib/test/test_zipfile.py Python-2.3b1/Lib/test/test_zipfile.py *** Python-2.3b1-orig/Lib/test/test_zipfile.py Tue Jul 23 13:04:09 2002 --- Python-2.3b1/Lib/test/test_zipfile.py Wed Jun 18 19:38:54 2003 *************** *** 76,78 **** --- 76,99 ---- else: raise TestFailed("expected creation of readable ZipFile without\n" " a file to raise an IOError.") + + + # Verify that testzip() doesn't swallow inappropriate exceptions. + data = StringIO.StringIO() + zipf = zipfile.ZipFile(data, mode="w") + zipf.writestr("foo.txt", "O, for a Muse of Fire!") + zipf.close() + zipf = zipfile.ZipFile(data, mode="r") + zipf.close() + try: + zipf.testzip() + except RuntimeError: + # This is correct; calling .read on a closed ZipFile should throw + # a RuntimeError, and so should calling .testzip. An earlier + # version of .testzip would swallow this exception (and any other) + # and report that the first file in the archive was corrupt. + pass + else: + raise TestFailed("expected calling .testzip on a closed ZipFile" + " to raise a RuntimeError") + del data, zipf diff -rc Python-2.3b1-orig/Lib/zipfile.py Python-2.3b1/Lib/zipfile.py *** Python-2.3b1-orig/Lib/zipfile.py Wed Jan 15 04:51:06 2003 --- Python-2.3b1/Lib/zipfile.py Wed Jun 18 20:09:14 2003 *************** *** 329,335 **** for zinfo in self.filelist: try: self.read(zinfo.filename) # Check CRC-32 ! except: return zinfo.filename def getinfo(self, name): --- 329,335 ---- for zinfo in self.filelist: try: self.read(zinfo.filename) # Check CRC-32 ! except BadZipfile: return zinfo.filename def getinfo(self, name):