diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2017-10-18 08:12:47 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-10-18 08:12:47 (GMT) |
commit | 95602b368b87da3702a0f340ded2a23e823bb104 (patch) | |
tree | 48698f6120f2e0ee60d3df01a3fefc9531d3473d /Modules | |
parent | 178148025494c4058571831fb11fc8eeff8b7365 (diff) | |
download | cpython-95602b368b87da3702a0f340ded2a23e823bb104.zip cpython-95602b368b87da3702a0f340ded2a23e823bb104.tar.gz cpython-95602b368b87da3702a0f340ded2a23e823bb104.tar.bz2 |
[3.6] bpo-31786: Make functions in the select module blocking when timeout is a small negative value. (GH-4003). (#4022)
(cherry picked from commit 2c15b29aea5d6b9c61aa42d2c24a07ff1edb4b46)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 3 | ||||
-rw-r--r-- | Modules/selectmodule.c | 16 |
2 files changed, 10 insertions, 9 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index ede675d..2eda03c 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3016,7 +3016,8 @@ check_time_rounding(int round) { if (round != _PyTime_ROUND_FLOOR && round != _PyTime_ROUND_CEILING - && round != _PyTime_ROUND_HALF_EVEN) { + && round != _PyTime_ROUND_HALF_EVEN + && round != _PyTime_ROUND_UP) { PyErr_SetString(PyExc_ValueError, "invalid rounding"); return -1; } diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 4a7fe00..9ae583b 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -213,7 +213,7 @@ select_select(PyObject *self, PyObject *args) tvp = (struct timeval *)NULL; else { if (_PyTime_FromSecondsObject(&timeout, timeout_obj, - _PyTime_ROUND_CEILING) < 0) { + _PyTime_ROUND_TIMEOUT) < 0) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_SetString(PyExc_TypeError, "timeout must be a float or None"); @@ -221,7 +221,7 @@ select_select(PyObject *self, PyObject *args) return NULL; } - if (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_CEILING) == -1) + if (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_TIMEOUT) == -1) return NULL; if (tv.tv_sec < 0) { PyErr_SetString(PyExc_ValueError, "timeout must be non-negative"); @@ -543,7 +543,7 @@ poll_poll(pollObject *self, PyObject *args) } else { if (_PyTime_FromMillisecondsObject(&timeout, timeout_obj, - _PyTime_ROUND_CEILING) < 0) { + _PyTime_ROUND_TIMEOUT) < 0) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_SetString(PyExc_TypeError, "timeout must be an integer or None"); @@ -551,7 +551,7 @@ poll_poll(pollObject *self, PyObject *args) return NULL; } - ms = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_CEILING); + ms = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_TIMEOUT); if (ms < INT_MIN || ms > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "timeout is too large"); return NULL; @@ -899,7 +899,7 @@ devpoll_poll(devpollObject *self, PyObject *args) } else { if (_PyTime_FromMillisecondsObject(&timeout, timeout_obj, - _PyTime_ROUND_CEILING) < 0) { + _PyTime_ROUND_TIMEOUT) < 0) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_SetString(PyExc_TypeError, "timeout must be an integer or None"); @@ -907,7 +907,7 @@ devpoll_poll(devpollObject *self, PyObject *args) return NULL; } - ms = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_CEILING); + ms = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_TIMEOUT); if (ms < -1 || ms > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "timeout is too large"); return NULL; @@ -1514,7 +1514,7 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds) /* epoll_wait() has a resolution of 1 millisecond, round towards infinity to wait at least timeout seconds. */ if (_PyTime_FromSecondsObject(&timeout, timeout_obj, - _PyTime_ROUND_CEILING) < 0) { + _PyTime_ROUND_TIMEOUT) < 0) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_SetString(PyExc_TypeError, "timeout must be an integer or None"); @@ -2129,7 +2129,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) } else { if (_PyTime_FromSecondsObject(&timeout, - otimeout, _PyTime_ROUND_CEILING) < 0) { + otimeout, _PyTime_ROUND_TIMEOUT) < 0) { PyErr_Format(PyExc_TypeError, "timeout argument must be a number " "or None, got %.200s", |