diff options
| author | Senthil Kumaran <senthil@uthcode.com> | 2011-10-19 17:38:35 (GMT) |
|---|---|---|
| committer | Senthil Kumaran <senthil@uthcode.com> | 2011-10-19 17:38:35 (GMT) |
| commit | ddd40312d502257adbcad4e9bdcecd237900f95a (patch) | |
| tree | ba7d3605cf23decd35be7fc0e4e5682a3d36afca /Lib/test/test_zipfile.py | |
| parent | 59a06d412d3a130c770faa1fc8d8fe13b0a67d3c (diff) | |
| download | cpython-ddd40312d502257adbcad4e9bdcecd237900f95a.zip cpython-ddd40312d502257adbcad4e9bdcecd237900f95a.tar.gz cpython-ddd40312d502257adbcad4e9bdcecd237900f95a.tar.bz2 | |
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 | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 6cba26c..7ebb663 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -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) |
