This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author staschuk
Recipients
Date 2003-06-19.02:49:38
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
ZipFile.testzip tries to call self.read, and reports the first 
file in the archive for which this raises an exception.  
Since a bare except is used, way too many kinds of 
exception are caught.  This causes weirdness such as

>>> import zipfile
>>> z = zipfile.ZipFile('foo.zip')
>>> z.close()
>>> z.testzip()
'nt.to.png'

When the ZipFile has been closed, .read raises a 
RuntimeError; .testzip reports this as a problem with the 
first file in the archive, which is misleading in the 
extreme.  Propagating the RuntimeError would be better.

Similarly IOErrors while reading the file are swallowed, 
as are KeyboardInterrupts, SystemExits, RuntimeErrors 
due to the absence of zlib...

The patch changes the except clause to catch only 
BadZipfile, which is explicitly raised in .read for checksum 
failures.  The docs indicate that that's what .testzip tests.  
(This exception is also raised for unsupported 
compression methods.  I'm not sure how .testzip should 
treat those; perhaps the two conditions should have 
different exception types.)

(A different bare except in this module received attention 
in bug 411881.)
History
Date User Action Args
2007-08-23 15:27:52adminlinkissue756996 messages
2007-08-23 15:27:52admincreate