[Python-checkins] cpython: Issue #22043: Fix _PyTime_gettimeofday() if HAVE_GETTIMEOFDAY

victor.stinner python-checkins at python.org
Tue Sep 2 23:01:58 CEST 2014


http://hg.python.org/cpython/rev/330bd57685fc
changeset:   92305:330bd57685fc
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Sep 02 23:01:40 2014 +0200
summary:
  Issue #22043: Fix _PyTime_gettimeofday() if HAVE_GETTIMEOFDAY

Ensure also that the tv_usec field is consistent: in range [0; 999999].

files:
  Python/pytime.c |  7 ++-----
  1 files changed, 2 insertions(+), 5 deletions(-)


diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -37,7 +37,6 @@
         info->resolution = timeIncrement * 1e-7;
         info->adjustable = 1;
     }
-    return 0;
 
 #else   /* MS_WINDOWS */
     int err;
@@ -67,11 +66,9 @@
         else
             info->resolution = 1e-9;
     }
-    return 0;
 #else   /* HAVE_CLOCK_GETTIME */
 
      /* test gettimeofday() */
-#ifdef HAVE_GETTIMEOFDAY
 #ifdef GETTIMEOFDAY_NO_TZ
     err = gettimeofday(tp);
 #else
@@ -89,10 +86,10 @@
         info->monotonic = 0;
         info->adjustable = 1;
     }
-    return 0;
-#endif   /* HAVE_GETTIMEOFDAY */
 #endif   /* !HAVE_CLOCK_GETTIME */
 #endif   /* !MS_WINDOWS */
+    assert(0 <= tp->tv_usec && tp->tv_usec < 1000 * 1000);
+    return 0;
 }
 
 void

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list