Fix error handling in timemodule.c

This commit is contained in:
Antoine Pitrou 2012-01-18 01:41:44 +01:00
parent 7422b22e5e
commit 2c085604b7
1 changed files with 6 additions and 2 deletions

View File

@ -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)
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);
} }