mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #1726687: time.mktime() will now correctly compute value one
second before epoch. Original patch by Peter Wang, reported by Martin Blais.
This commit is contained in:
parent
7234479580
commit
b7d40d1702
2 changed files with 17 additions and 1 deletions
|
@ -339,6 +339,19 @@ class _Test4dYear(_BaseYearTest):
|
|||
self.assertEqual(self.yearstr(-1234), '-1234')
|
||||
self.assertEqual(self.yearstr(-123456), '-123456')
|
||||
|
||||
|
||||
def test_mktime(self):
|
||||
# Issue #1726687
|
||||
for t in (-2, -1, 0, 1):
|
||||
try:
|
||||
tt = time.localtime(t)
|
||||
except (OverflowError, ValueError):
|
||||
pass
|
||||
self.assertEqual(time.mktime(tt), t)
|
||||
# Hopefully year = -1 is enough to make OS mktime fail
|
||||
self.assertRaises(OverflowError, time.mktime,
|
||||
(-1, 1, 1, 0, 0, 0, -1, -1, -1))
|
||||
|
||||
class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue