https://github.com/python/cpython/commit/1597d00d96057aaad82dc201d493044b609df42b
commit: 1597d00d96057aaad82dc201d493044b609df42b
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-01-15T11:54:30+01:00
summary:

gh-80620: Fix test_time.test_gmtime() for 32-bit time_t (#143861)

files:
M Lib/test/test_time.py

diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index ce13f3a22f3ae5..c360f4a64c266b 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -192,18 +192,29 @@ def test_gmtime(self):
         # (tm_year, tm_mon, tm_mday,
         #  tm_hour, tm_min, tm_sec,
         #  tm_wday, tm_yday)
-        for t, expected in (
+        tests = [
             (-13262400, (1969, 7, 31, 12, 0, 0, 3, 212)),
             (-6177600, (1969, 10, 21, 12, 0, 0, 1, 294)),
-            # non-leap years (pre epoch)
-            (-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
-            (-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
-            (-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
-            (-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
             # leap years (pre epoch)
             (-2077660800, (1904, 3, 1, 0, 0, 0, 1, 61)),
             (-2077833600, (1904, 2, 28, 0, 0, 0, 6, 59)),
-        ):
+        ]
+
+        try:
+            from _testinternalcapi import SIZEOF_TIME_T
+        except ImportError:
+            pass
+        else:
+            if SIZEOF_TIME_T >= 8:
+                tests.extend((
+                    # non-leap years (pre epoch)
+                    (-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
+                    (-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
+                    (-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
+                    (-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
+                ))
+
+        for t, expected in tests:
             with self.subTest(t=t, expected=expected):
                 res = time.gmtime(t)
                 self.assertEqual(tuple(res)[:8], expected, res)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to