Skip to content

Commit

Permalink
Fix test_datetime on system with 32-bit time_t
Browse files Browse the repository at this point in the history
Issue #29100: Catch OverflowError in the new test_timestamp_limits() test.
  • Loading branch information
vstinner committed Feb 10, 2017
1 parent b67f096 commit 6f37e36
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,9 +1993,13 @@ def test_timestamp_limits(self):
# minimum timestamp
min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
min_ts = min_dt.timestamp()
# date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
min_dt)
try:
# date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
min_dt)
except OverflowError as exc:
# the date 0001-01-01 doesn't fit into 32-bit time_t
self.skipTest(str(exc))

# maximum timestamp: set seconds to zero to avoid rounding issues
max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
Expand Down

0 comments on commit 6f37e36

Please sign in to comment.