Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 60972) +++ Modules/posixmodule.c (working copy) @@ -5922,9 +5922,6 @@ #ifdef HAVE_TIMES -#ifndef HZ -#define HZ 60 /* Universal constant :-) */ -#endif /* HZ */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) static long @@ -5944,28 +5941,42 @@ { /* Currently Only Uptime is Provided -- Others Later */ return Py_BuildValue("ddddd", - (double)0 /* t.tms_utime / HZ */, - (double)0 /* t.tms_stime / HZ */, - (double)0 /* t.tms_cutime / HZ */, - (double)0 /* t.tms_cstime / HZ */, + (double)0 /* t.tms_utime / ticks_per_sec */, + (double)0 /* t.tms_stime / ticks_per_sec */, + (double)0 /* t.tms_cutime / ticks_per_sec */, + (double)0 /* t.tms_cstime / ticks_per_sec */, (double)system_uptime() / 1000); } #else /* not OS2 */ static PyObject * posix_times(PyObject *self, PyObject *noargs) { +#ifdef HAVE_SYSCONF + clock_t ticks_per_sec = sysconf(_SC_CLK_TCK); +#else +#ifdef HZ + clock_t ticks_per_sec = HZ; +#else + clock_t ticks_per_sec = NULL; +#endif +#endif struct tms t; clock_t c; errno = 0; + if (ticks_per_sec == NULL) { + PyErr_SetString(PyExc_EnvironmentError, + "Clock information is not available for this platform"); + return NULL; + } c = times(&t); if (c == (clock_t) -1) return posix_error(); return Py_BuildValue("ddddd", - (double)t.tms_utime / HZ, - (double)t.tms_stime / HZ, - (double)t.tms_cutime / HZ, - (double)t.tms_cstime / HZ, - (double)c / HZ); + (double)t.tms_utime / ticks_per_sec, + (double)t.tms_stime / ticks_per_sec, + (double)t.tms_cutime / ticks_per_sec, + (double)t.tms_cstime / ticks_per_sec, + (double)c / ticks_per_sec); } #endif /* not OS2 */ #endif /* HAVE_TIMES */