Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8798ad3

Browse files
committed
struct timeval.tv_usec is 4 bytes on 64-bit OS X as it should be, but
is defined as an int while everyone else expects a long regardless of length.
1 parent 014397e commit 8798ad3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Modules/selectmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,12 @@ select_select(PyObject *self, PyObject *args)
237237
#endif
238238
tv.tv_sec = (long)sec;
239239
#else
240-
if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv.tv_usec) == -1)
240+
/* 64-bit OS X has struct timeval.tv_usec as an int (and thus still 4
241+
bytes as required), but no longer defined by a long. */
242+
long tv_usec = tv.tv_usec;
243+
if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1)
241244
return NULL;
245+
tv.tv_usec = tv_usec;
242246
#endif
243247
if (tv.tv_sec < 0) {
244248
PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");

0 commit comments

Comments
 (0)