Message44072
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.) |
|
Date |
User |
Action |
Args |
2007-08-23 15:27:52 | admin | link | issue756996 messages |
2007-08-23 15:27:52 | admin | create | |
|