diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-10-19 17:52:41 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-10-19 17:52:41 (GMT) |
commit | 7e3062b320a52f7b73751c432c33c1e46085de59 (patch) | |
tree | 782efcd6163394bd6d8c324f2e40f72e1b196708 /Lib/test/test_zipfile.py | |
parent | 294c231aa5a9b52fca429209c6091d44c8060008 (diff) | |
parent | 29fa9d4d68af7d22b88545fa8bc4ae186d256fd3 (diff) | |
download | cpython-7e3062b320a52f7b73751c432c33c1e46085de59.zip cpython-7e3062b320a52f7b73751c432c33c1e46085de59.tar.gz cpython-7e3062b320a52f7b73751c432c33c1e46085de59.tar.bz2 |
default - 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.
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r-- | Lib/test/test_zipfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 4dcb690..0b3a694 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -500,6 +500,18 @@ 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) + + + + + + + @requires_zlib def test_unicode_filenames(self): # bug #10801 @@ -1046,6 +1058,10 @@ class OtherTests(unittest.TestCase): f.close() 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) |