mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
[3.6] bpo-31806: Use _PyTime_ROUND_TIMEOUT for the timeout argument parsing in more functions (GH-4026) (#4032)
Fix timeout rounding in time.sleep(), threading.Lock.acquire() and
socket.socket.settimeout() to round correctly negative timeouts between -1.0 and
0.0. The functions now block waiting for events as expected. Previously, the
call was incorrectly non-blocking.
(cherry picked from commit 59af94fa61
)
This commit is contained in:
parent
95602b368b
commit
be4e9cc769
4 changed files with 10 additions and 6 deletions
|
@ -111,7 +111,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
|
||||
if (timeout_obj
|
||||
&& _PyTime_FromSecondsObject(timeout,
|
||||
timeout_obj, _PyTime_ROUND_CEILING) < 0)
|
||||
timeout_obj, _PyTime_ROUND_TIMEOUT) < 0)
|
||||
return -1;
|
||||
|
||||
if (!blocking && *timeout != unset_timeout ) {
|
||||
|
@ -129,7 +129,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
else if (*timeout != unset_timeout) {
|
||||
_PyTime_t microseconds;
|
||||
|
||||
microseconds = _PyTime_AsMicroseconds(*timeout, _PyTime_ROUND_CEILING);
|
||||
microseconds = _PyTime_AsMicroseconds(*timeout, _PyTime_ROUND_TIMEOUT);
|
||||
if (microseconds >= PY_TIMEOUT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"timeout value is too large");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue