diff -r 0ce5151fe57e Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py Tue Jan 03 23:47:39 2017 +0100 +++ b/Lib/test/datetimetester.py Wed Jan 04 00:10:29 2017 +0100 @@ -1989,6 +1989,26 @@ class TestDateTime(TestDate): self.assertEqual(t.second, 0) self.assertEqual(t.microsecond, 7812) + def test_fromtimestamp_limits(self): + # number of seconds greater than 1 year + delta = 3600 * 24 * 400 + + # too small + try: + ts = self.theclass.min.timestamp() - delta + except OverflowError: + ts = -62101036800 + self.assertRaises(OverflowError, self.theclass.fromtimestamp, ts) + self.assertRaises(OverflowError, self.theclass.utcfromtimestamp, ts) + + # too big + try: + ts = self.theclass.max.timestamp() + delta + except OverflowError: + ts = 253436860800 + self.assertRaises(OverflowError, self.theclass.fromtimestamp, ts) + self.assertRaises(OverflowError, self.theclass.utcfromtimestamp, ts) + def test_insane_fromtimestamp(self): # It's possible that some platform maps time_t to double, # and that this test will fail there. This test should