"""
OVERFLOW_SECONDS = None
+ def setUp(self):
+ from _testcapi import SIZEOF_TIME_T
+ bits = SIZEOF_TIME_T * 8 - 1
+ self.time_t_min = -2 ** bits
+ self.time_t_max = 2 ** bits - 1
+
+ def time_t_filter(self, seconds):
+ return (self.time_t_min <= seconds <= self.time_t_max)
+
def _rounding_values(self, use_float):
"Build timestamps used to test rounding."
def seconds_filter(secs):
return LONG_MIN <= secs <= LONG_MAX
else:
- seconds_filter = None
+ seconds_filter = self.time_t_filter
self.check_int_rounding(PyTime_AsTimeval,
timeval_converter,
self.check_int_rounding(lambda ns, rnd: PyTime_AsTimespec(ns),
timespec_converter,
- NS_TO_SEC)
+ NS_TO_SEC,
+ value_filter=self.time_t_filter)
def test_AsMilliseconds(self):
from _testcapi import PyTime_AsMilliseconds
from _testcapi import pytime_object_to_time_t
self.check_int_rounding(pytime_object_to_time_t,
- lambda secs: secs)
+ lambda secs: secs,
+ value_filter=self.time_t_filter)
self.check_float_rounding(pytime_object_to_time_t,
self.decimal_round)
from _testcapi import pytime_object_to_timeval
self.check_int_rounding(pytime_object_to_timeval,
- lambda secs: (secs, 0))
+ lambda secs: (secs, 0),
+ value_filter=self.time_t_filter)
self.check_float_rounding(pytime_object_to_timeval,
self.create_converter(SEC_TO_US))
from _testcapi import pytime_object_to_timespec
self.check_int_rounding(pytime_object_to_timespec,
- lambda secs: (secs, 0))
+ lambda secs: (secs, 0),
+ value_filter=self.time_t_filter)
self.check_float_rounding(pytime_object_to_timespec,
self.create_converter(SEC_TO_NS))
PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX));
PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN));
PyModule_AddObject(m, "SIZEOF_PYGC_HEAD", PyLong_FromSsize_t(sizeof(PyGC_Head)));
+ PyModule_AddObject(m, "SIZEOF_TIME_T", PyLong_FromSsize_t(sizeof(time_t)));
Py_INCREF(&PyInstanceMethod_Type);
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);