summaryrefslogtreecommitdiffstats
path: root/Modules/selectmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-16 23:02:43 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-16 23:02:43 (GMT)
commit3c1b379ebd701cbd7686d0f0be95b88c5b3da8fe (patch)
treec1759ff720c8226c333052f6773c97d5b5c6356e /Modules/selectmodule.c
parent23f628de4ab75acde14de9593793e67ec74d851c (diff)
downloadcpython-3c1b379ebd701cbd7686d0f0be95b88c5b3da8fe.zip
cpython-3c1b379ebd701cbd7686d0f0be95b88c5b3da8fe.tar.gz
cpython-3c1b379ebd701cbd7686d0f0be95b88c5b3da8fe.tar.bz2
Issue #20320: select.select() and select.kqueue.control() now round the timeout
aways from zero, instead of rounding towards zero. It should make test_asyncio more reliable, especially test_timeout_rounding() test.
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r--Modules/selectmodule.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 0b11a01..8f8f606 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -214,7 +214,8 @@ select_select(PyObject *self, PyObject *args)
else {
#ifdef MS_WINDOWS
time_t sec;
- if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec) == -1)
+ if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec,
+ _PyTime_ROUND_UP) == -1)
return NULL;
assert(sizeof(tv.tv_sec) == sizeof(long));
#if SIZEOF_TIME_T > SIZEOF_LONG
@@ -229,7 +230,8 @@ select_select(PyObject *self, PyObject *args)
/* 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;
- if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1)
+ if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec,
+ _PyTime_ROUND_UP) == -1)
return NULL;
tv.tv_usec = tv_usec;
#endif
@@ -2037,8 +2039,8 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
ptimeoutspec = NULL;
}
else if (PyNumber_Check(otimeout)) {
- if (_PyTime_ObjectToTimespec(otimeout,
- &timeout.tv_sec, &timeout.tv_nsec) == -1)
+ if (_PyTime_ObjectToTimespec(otimeout, &timeout.tv_sec,
+ &timeout.tv_nsec, _PyTime_ROUND_UP) == -1)
return NULL;
if (timeout.tv_sec < 0) {