mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22117: Use the _PyTime_t API for time.clock_settime()
Remove also the now unused _PyTime_AddDouble() function.
This commit is contained in:
parent
c337838af7
commit
b3b4544070
3 changed files with 5 additions and 27 deletions
|
@ -166,18 +166,18 @@ time_clock_settime(PyObject *self, PyObject *args)
|
|||
{
|
||||
int clk_id;
|
||||
PyObject *obj;
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
_PyTime_t t;
|
||||
struct timespec tp;
|
||||
int ret;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj))
|
||||
return NULL;
|
||||
|
||||
if (_PyTime_ObjectToTimespec(obj, &tv_sec, &tv_nsec, _PyTime_ROUND_DOWN) == -1)
|
||||
if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_DOWN) < 0)
|
||||
return NULL;
|
||||
|
||||
if (_PyTime_AsTimespec(t, &tp) == -1)
|
||||
return NULL;
|
||||
tp.tv_sec = tv_sec;
|
||||
tp.tv_nsec = tv_nsec;
|
||||
|
||||
ret = clock_settime((clockid_t)clk_id, &tp);
|
||||
if (ret != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue