mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
bpo-31786: Make functions in the select module blocking when timeout is a small negative value. (#4003)
This commit is contained in:
parent
552be9d7e6
commit
2c15b29aea
7 changed files with 65 additions and 12 deletions
|
@ -120,9 +120,13 @@ _PyTime_Round(double x, _PyTime_round_t round)
|
|||
else if (round == _PyTime_ROUND_CEILING) {
|
||||
d = ceil(d);
|
||||
}
|
||||
else {
|
||||
else if (round == _PyTime_ROUND_FLOOR) {
|
||||
d = floor(d);
|
||||
}
|
||||
else {
|
||||
assert(round == _PyTime_ROUND_UP);
|
||||
d = (d >= 0.0) ? ceil(d) : floor(d);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -427,7 +431,7 @@ _PyTime_Divide(const _PyTime_t t, const _PyTime_t k,
|
|||
return t / k;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (round == _PyTime_ROUND_FLOOR){
|
||||
if (t >= 0) {
|
||||
return t / k;
|
||||
}
|
||||
|
@ -435,6 +439,15 @@ _PyTime_Divide(const _PyTime_t t, const _PyTime_t k,
|
|||
return (t - (k - 1)) / k;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert(round == _PyTime_ROUND_UP);
|
||||
if (t >= 0) {
|
||||
return (t + k - 1) / k;
|
||||
}
|
||||
else {
|
||||
return (t - (k - 1)) / k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_PyTime_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue