@@ -680,6 +680,15 @@ class CPyTimeTestCase:
680680 """
681681 OVERFLOW_SECONDS = None
682682
683+ def setUp (self ):
684+ from _testcapi import SIZEOF_TIME_T
685+ bits = SIZEOF_TIME_T * 8 - 1
686+ self .time_t_min = - 2 ** bits
687+ self .time_t_max = 2 ** bits - 1
688+
689+ def time_t_filter (self , seconds ):
690+ return (self .time_t_min <= seconds <= self .time_t_max )
691+
683692 def _rounding_values (self , use_float ):
684693 "Build timestamps used to test rounding."
685694
@@ -858,7 +867,7 @@ def timeval_converter(ns):
858867 def seconds_filter (secs ):
859868 return LONG_MIN <= secs <= LONG_MAX
860869 else :
861- seconds_filter = None
870+ seconds_filter = self . time_t_filter
862871
863872 self .check_int_rounding (PyTime_AsTimeval ,
864873 timeval_converter ,
@@ -875,7 +884,8 @@ def timespec_converter(ns):
875884
876885 self .check_int_rounding (lambda ns , rnd : PyTime_AsTimespec (ns ),
877886 timespec_converter ,
878- NS_TO_SEC )
887+ NS_TO_SEC ,
888+ value_filter = self .time_t_filter )
879889
880890 def test_AsMilliseconds (self ):
881891 from _testcapi import PyTime_AsMilliseconds
@@ -904,7 +914,8 @@ def test_object_to_time_t(self):
904914 from _testcapi import pytime_object_to_time_t
905915
906916 self .check_int_rounding (pytime_object_to_time_t ,
907- lambda secs : secs )
917+ lambda secs : secs ,
918+ value_filter = self .time_t_filter )
908919
909920 self .check_float_rounding (pytime_object_to_time_t ,
910921 self .decimal_round )
@@ -928,7 +939,8 @@ def test_object_to_timeval(self):
928939 from _testcapi import pytime_object_to_timeval
929940
930941 self .check_int_rounding (pytime_object_to_timeval ,
931- lambda secs : (secs , 0 ))
942+ lambda secs : (secs , 0 ),
943+ value_filter = self .time_t_filter )
932944
933945 self .check_float_rounding (pytime_object_to_timeval ,
934946 self .create_converter (SEC_TO_US ))
@@ -937,7 +949,8 @@ def test_object_to_timespec(self):
937949 from _testcapi import pytime_object_to_timespec
938950
939951 self .check_int_rounding (pytime_object_to_timespec ,
940- lambda secs : (secs , 0 ))
952+ lambda secs : (secs , 0 ),
953+ value_filter = self .time_t_filter )
941954
942955 self .check_float_rounding (pytime_object_to_timespec ,
943956 self .create_converter (SEC_TO_NS ))
0 commit comments