summaryrefslogtreecommitdiff
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-09-03 09:43:48 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-09-03 09:43:48 +0200
commit5789cfbb5650b6a4dc92cb466831dabad9f3b42d (patch)
treeea6b2fec2857147d1a855380e93ae7800df7c565 /Python/pytime.c
parentae58649721ec898ea4a101b0861e16fff3511cfa (diff)
downloadcpython-git-5789cfbb5650b6a4dc92cb466831dabad9f3b42d.tar.gz
Issue #22043: Fix pymonotonic(), use tv_usec=-1 as a marker to skip
the monotonic test
Diffstat (limited to 'Python/pytime.c')
-rw-r--r--Python/pytime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 9964195378..a8460c6867 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -121,7 +121,7 @@ static int
pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
{
#ifdef Py_DEBUG
- static _PyTime_timeval last = {-1, -1};
+ static _PyTime_timeval last = {0, -1};
#endif
#if defined(MS_WINDOWS)
static ULONGLONG (*GetTickCount64) (void) = NULL;
@@ -247,7 +247,8 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
assert(0 <= tp->tv_usec && tp->tv_usec < 1000 * 1000);
#ifdef Py_DEBUG
/* monotonic clock cannot go backward */
- assert(tp->tv_sec > last.tv_sec
+ assert(last.tv_usec == -1
+ || tp->tv_sec > last.tv_sec
|| (tp->tv_sec == last.tv_sec && tp->tv_usec >= last.tv_usec));
last = *tp;
#endif