bpo-31786: Make functions in the select module blocking when timeout is a small negative value. (#4003)

This commit is contained in:
Pablo Galindo 2017-10-17 15:14:41 +01:00 committed by Serhiy Storchaka
parent 552be9d7e6
commit 2c15b29aea
7 changed files with 65 additions and 12 deletions

View file

@ -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