]> granicus.if.org Git - python/commitdiff
struct timeval.tv_usec is 4 bytes on 64-bit OS X as it should be, but
authorBrett Cannon <brett@python.org>
Sat, 7 Apr 2012 18:59:29 +0000 (14:59 -0400)
committerBrett Cannon <brett@python.org>
Sat, 7 Apr 2012 18:59:29 +0000 (14:59 -0400)
is defined as an int while everyone else expects a long regardless of
length.

Modules/selectmodule.c

index 9cb7481f24ef7bac8087a1d772e2d27c5ebfc700..8964b675fcb3634d231642baa6254b577bbf7b71 100644 (file)
@@ -237,8 +237,12 @@ select_select(PyObject *self, PyObject *args)
 #endif
         tv.tv_sec = (long)sec;
 #else
-        if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv.tv_usec) == -1)
+        /* 64-bit OS X has struct timeval.tv_usec as an int (and thus still 4
+           bytes as required), but no longer defined by a long. */
+        long tv_usec = tv.tv_usec;
+        if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1)
             return NULL;
+        tv.tv_usec = tv_usec;
 #endif
         if (tv.tv_sec < 0) {
             PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");