Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f37e36

Browse files
committed
Fix test_datetime on system with 32-bit time_t
Issue python#29100: Catch OverflowError in the new test_timestamp_limits() test.
1 parent b67f096 commit 6f37e36

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/datetimetester.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1993,9 +1993,13 @@ def test_timestamp_limits(self):
19931993
# minimum timestamp
19941994
min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
19951995
min_ts = min_dt.timestamp()
1996-
# date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
1997-
self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
1998-
min_dt)
1996+
try:
1997+
# date 0001-01-01 00:00:00+00:00: timestamp=-62135596800
1998+
self.assertEqual(self.theclass.fromtimestamp(min_ts, tz=timezone.utc),
1999+
min_dt)
2000+
except OverflowError as exc:
2001+
# the date 0001-01-01 doesn't fit into 32-bit time_t
2002+
self.skipTest(str(exc))
19992003

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

0 commit comments

Comments
 (0)