Commit 2c085604 authored by Antoine Pitrou's avatar Antoine Pitrou

Fix error handling in timemodule.c

parent 7422b22e
...@@ -128,8 +128,10 @@ time_clock_gettime(PyObject *self, PyObject *args) ...@@ -128,8 +128,10 @@ time_clock_gettime(PyObject *self, PyObject *args)
return NULL; return NULL;
ret = clock_gettime((clockid_t)clk_id, &tp); ret = clock_gettime((clockid_t)clk_id, &tp);
if (ret != 0) if (ret != 0) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9); return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9);
} }
...@@ -152,8 +154,10 @@ time_clock_getres(PyObject *self, PyObject *args) ...@@ -152,8 +154,10 @@ time_clock_getres(PyObject *self, PyObject *args)
return NULL; return NULL;
ret = clock_getres((clockid_t)clk_id, &tp); ret = clock_getres((clockid_t)clk_id, &tp);
if (ret != 0) if (ret != 0) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9); return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment