[Python-checkins] cpython: Issue #15413: os.times() had disappeared under Windows.
antoine.pitrou
python-checkins at python.org
Tue Jul 24 21:26:01 CEST 2012
http://hg.python.org/cpython/rev/d9a881b0d6ca
changeset: 78272:d9a881b0d6ca
parent: 78270:d53524c43d0e
user: Antoine Pitrou <solipsis at pitrou.net>
date: Tue Jul 24 21:23:53 2012 +0200
summary:
Issue #15413: os.times() had disappeared under Windows.
files:
Misc/NEWS | 2 +
Modules/posixmodule.c | 54 +++++++++++++++---------------
2 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,8 @@
Library
-------
+- Issue #15413: os.times() had disappeared under Windows.
+
- Issue #15402: An issue in the struct module that caused sys.getsizeof to
return incorrect results for struct.Struct instances has been fixed.
Initial patch by Serhiy Storchaka.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7453,8 +7453,11 @@
static PyTypeObject TimesResultType;
-
-#if defined(HAVE_TIMES) || defined(MS_WINDOWS)
+#ifdef MS_WINDOWS
+#define HAVE_TIMES /* mandatory, for the method table */
+#endif
+
+#ifdef HAVE_TIMES
static PyObject *
build_times_result(double user, double system,
@@ -7492,10 +7495,6 @@
times. The object behaves like a named tuple with these fields:\n\
(utime, stime, cutime, cstime, elapsed_time)");
-#endif
-
-
-#ifdef HAVE_TIMES
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
static long
system_uptime(void)
@@ -7520,26 +7519,6 @@
(double)0 /* t.tms_cstime / HZ */,
(double)system_uptime() / 1000);
}
-#else /* not OS2 */
-#define NEED_TICKS_PER_SECOND
-static long ticks_per_second = -1;
-static PyObject *
-posix_times(PyObject *self, PyObject *noargs)
-{
- struct tms t;
- clock_t c;
- errno = 0;
- c = times(&t);
- if (c == (clock_t) -1)
- return posix_error();
- return build_times_result(
- (double)t.tms_utime / ticks_per_second,
- (double)t.tms_stime / ticks_per_second,
- (double)t.tms_cutime / ticks_per_second,
- (double)t.tms_cstime / ticks_per_second,
- (double)c / ticks_per_second);
-}
-#endif /* not OS2 */
#elif defined(MS_WINDOWS)
static PyObject *
posix_times(PyObject *self, PyObject *noargs)
@@ -7562,7 +7541,28 @@
(double)0,
(double)0);
}
-#endif
+#else /* Neither Windows nor OS/2 */
+#define NEED_TICKS_PER_SECOND
+static long ticks_per_second = -1;
+static PyObject *
+posix_times(PyObject *self, PyObject *noargs)
+{
+ struct tms t;
+ clock_t c;
+ errno = 0;
+ c = times(&t);
+ if (c == (clock_t) -1)
+ return posix_error();
+ return build_times_result(
+ (double)t.tms_utime / ticks_per_second,
+ (double)t.tms_stime / ticks_per_second,
+ (double)t.tms_cutime / ticks_per_second,
+ (double)t.tms_cstime / ticks_per_second,
+ (double)c / ticks_per_second);
+}
+#endif
+
+#endif /* HAVE_TIMES */
#ifdef HAVE_GETSID
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list