cpython: 27441e0d6a75 (original) (raw)

--- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -226,7 +226,7 @@ The module defines the following functio The earliest date for which it can generate a time is platform-dependent. -.. function:: steady() +.. function:: steady(strict=False) .. index:: single: benchmarking @@ -236,6 +236,11 @@ The module defines the following functio adjusted. The reference point of the returned value is undefined so only the difference of consecutive calls is valid.

--- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -340,6 +340,16 @@ class TimeTestCase(unittest.TestCase): self.assertGreater(t2, t1) self.assertAlmostEqual(dt, 0.1, delta=0.2)

+ def test_localtime_failure(self): # Issue #13847: check for localtime() failure invalid_time_t = None

--- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -45,18 +45,12 @@ /* Forward declarations / static int floatsleep(double); -static double floattime(void); +static PyObject floattime(void); static PyObject * time_time(PyObject *self, PyObject *unused) {

} PyDoc_STRVAR(time_doc, @@ -768,11 +762,11 @@ the local timezone used by methods such should not be relied on."); #endif /* HAVE_WORKING_TZSET */ -static PyObject * -time_steady(PyObject *self, PyObject unused) +static PyObject +steady_clock(int strict) { #if defined(MS_WINDOWS) && !defined(BORLANDC)

#elif defined(APPLE) uint64_t time = mach_absolute_time(); double secs; @@ -806,14 +800,37 @@ time_steady(PyObject *self, PyObject *un if (Py_ARRAY_LENGTH(clk_ids) <= clk_index) clk_index = -1; }

#else

#endif } +static PyObject * +time_steady(PyObject *self, PyObject *args, PyObject *kwargs) +{

+

+

+} + PyDoc_STRVAR(steady_doc, -"steady() -> float\n[](#l3.75) +"steady(strict=False) -> float\n[](#l3.76) \n[](#l3.77) Return the current time as a floating point number expressed in seconds.\n[](#l3.78) This clock advances at a steady rate relative to real time and it may not\n[](#l3.79) @@ -949,7 +966,8 @@ static PyMethodDef time_methods[] = { #ifdef HAVE_MKTIME {"mktime", time_mktime, METH_O, mktime_doc}, #endif

#ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif @@ -1041,12 +1059,18 @@ PyInit_time(void) return m; } -static double +static PyObject* floattime(void) { _PyTime_timeval t;

}