diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 17 | ||||
-rw-r--r-- | Modules/timemodule.c | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index b8e1dbc..ec513bc 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3378,6 +3378,22 @@ return_result_with_error(PyObject *self, PyObject *args) Py_RETURN_NONE; } +static PyObject * +test_pytime_fromsecondsobject(PyObject *self, PyObject *args) +{ + PyObject *obj; + int round; + _PyTime_t ts; + + if (!PyArg_ParseTuple(args, "Oi", &obj, &round)) + return NULL; + if (check_time_rounding(round) < 0) + return NULL; + if (_PyTime_FromSecondsObject(&ts, obj, round) == -1) + return NULL; + return _PyTime_AsNanosecondsObject(ts); +} + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, @@ -3541,6 +3557,7 @@ static PyMethodDef TestMethods[] = { return_null_without_error, METH_NOARGS}, {"return_result_with_error", return_result_with_error, METH_NOARGS}, + {"pytime_fromsecondsobject", test_pytime_fromsecondsobject, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/timemodule.c b/Modules/timemodule.c index e44e082..1ce2f6a 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -221,7 +221,7 @@ static PyObject * time_sleep(PyObject *self, PyObject *obj) { _PyTime_t secs; - if (_PyTime_FromObject(&secs, obj, _PyTime_ROUND_UP)) + if (_PyTime_FromSecondsObject(&secs, obj, _PyTime_ROUND_UP)) return NULL; if (secs < 0) { PyErr_SetString(PyExc_ValueError, |