gh-123974: Fix time.get_clock_info() on NetBSD (#123975)

Fix OSError for thread_time clock on NetBSD by setting default resolution.
This commit is contained in:
Furkan Onder 2024-09-13 23:34:25 +03:00 committed by GitHub
parent ea77973718
commit b1d6f8a2ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -1509,15 +1509,19 @@ _PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
return -1;
}
if (info) {
struct timespec res;
info->implementation = function;
info->monotonic = 1;
info->adjustable = 0;
#if defined(__NetBSD__)
info->resolution = 1e-9;
#else
struct timespec res;
if (clock_getres(clk_id, &res)) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
}
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
#endif
}
if (_PyTime_FromTimespec(tp, &ts) < 0) {