mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix closes Issue6090 - Raise a ValueError, instead of failing with unrelated
exceptions, when a document with timestamp earlier than 1980 is provided to zipfile. Patch contributed by Petri Lehtinen.
This commit is contained in:
parent
59a06d412d
commit
ddd40312d5
4 changed files with 22 additions and 1 deletions
|
@ -477,6 +477,12 @@ class TestsWithSourceFile(unittest.TestCase):
|
|||
except zipfile.BadZipfile:
|
||||
self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
|
||||
|
||||
def test_add_file_before_1980(self):
|
||||
# Set atime and mtime to 1970-01-01
|
||||
os.utime(TESTFN, (0, 0))
|
||||
with zipfile.ZipFile(TESTFN2, "w") as zipfp:
|
||||
self.assertRaises(ValueError, zipfp.write, TESTFN)
|
||||
|
||||
def tearDown(self):
|
||||
unlink(TESTFN)
|
||||
unlink(TESTFN2)
|
||||
|
@ -990,6 +996,10 @@ class OtherTests(unittest.TestCase):
|
|||
pass
|
||||
self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN, 'r')
|
||||
|
||||
def test_create_zipinfo_before_1980(self):
|
||||
self.assertRaises(ValueError,
|
||||
zipfile.ZipInfo, 'seventies', (1979, 1, 1, 0, 0, 0))
|
||||
|
||||
def tearDown(self):
|
||||
unlink(TESTFN)
|
||||
unlink(TESTFN2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue