[Python-checkins] cpython: Try to fix _PyTime_AsTimevalStruct_impl() on OpenBSD

victor.stinner python-checkins at python.org
Tue Sep 29 13:43:06 CEST 2015


https://hg.python.org/cpython/rev/28d3bcb1bad6
changeset:   98380:28d3bcb1bad6
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Sep 29 13:41:46 2015 +0200
summary:
  Try to fix _PyTime_AsTimevalStruct_impl() on OpenBSD

It looks like the check for integer overflow doesn't work on x86 OpenBSD 5.8.

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


diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -454,7 +454,7 @@
 _PyTime_AsTimevalStruct_impl(_PyTime_t t, struct timeval *tv,
                              _PyTime_round_t round, int raise)
 {
-    _PyTime_t secs;
+    _PyTime_t secs, secs2;
     int us;
     int res;
 
@@ -467,7 +467,8 @@
 #endif
     tv->tv_usec = us;
 
-    if (res < 0 || (_PyTime_t)tv->tv_sec != secs) {
+    secs2 = (_PyTime_t)tv->tv_sec;
+    if (res < 0 || secs2 != secs) {
         if (raise)
             error_time_t_overflow();
         return -1;

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


More information about the Python-checkins mailing list