From b2a7d718e3b70922f46208c22750c33145dccb75 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:54:09 +0200 Subject: [PATCH] [3.12] gh-123974: Fix time.get_clock_info() on NetBSD (GH-123975) (#124073) 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 b1d6f8a2ee04215c64aa8752cc515b7e98a08d28) Co-authored-by: Furkan Onder --- Modules/timemodule.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 8613fccfe022..124efc8364bf 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -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) { -- 2.47.3