mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
#6511: ZipFile will now raise BadZipfile when opening an empty or tiny file,
like it does for larger invalid files.
This commit is contained in:
parent
e55df1fa2a
commit
3e5b027a64
3 changed files with 17 additions and 1 deletions
|
@ -703,6 +703,16 @@ class OtherTests(unittest.TestCase):
|
|||
# quickly.
|
||||
self.assertRaises(IOError, zipfile.ZipFile, TESTFN)
|
||||
|
||||
def test_empty_file_raises_BadZipFile(self):
|
||||
f = open(TESTFN, 'w')
|
||||
f.close()
|
||||
self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
|
||||
|
||||
f = open(TESTFN, 'w')
|
||||
f.write("short file")
|
||||
f.close()
|
||||
self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
|
||||
|
||||
def test_closed_zip_raises_RuntimeError(self):
|
||||
# Verify that testzip() doesn't swallow inappropriate exceptions.
|
||||
data = StringIO()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue