]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123974: Fix time.get_clock_info() on NetBSD (#123975)
authorFurkan Onder <furkanonder@protonmail.com>
Fri, 13 Sep 2024 20:34:25 +0000 (23:34 +0300)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2024 20:34:25 +0000 (22:34 +0200)
Fix OSError for thread_time clock on NetBSD by setting default resolution.

Modules/timemodule.c

index 46f85bc9c30f9c399545d79dc7b12f66dde46c8d..cfbb26b025950438f078c0e29d2e5c1587367254 100644 (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) {