Skip to content

Commit

Permalink
[3.12] gh-123974: Fix time.get_clock_info() on NetBSD (GH-123975) (#1…
Browse files Browse the repository at this point in the history
…24073)

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

Fix OSError for thread_time clock on NetBSD by setting default resolution.
(cherry picked from commit b1d6f8a)

Co-authored-by: Furkan Onder <[email protected]>
  • Loading branch information
miss-islington and furkanonder authored Sep 13, 2024
1 parent 84e3f60 commit b2a7d71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,15 +1525,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) {
Expand Down

0 comments on commit b2a7d71

Please sign in to comment.