[3.6] bpo-30807: signal.setitimer() may disable the timer by mistake (GH-2493) (#2497)

* bpo-30807: signal.setitimer() may disable the timer by mistake

* Add NEWS blurb
(cherry picked from commit 729780a810)
This commit is contained in:
Antoine Pitrou 2017-06-30 10:54:24 +02:00 committed by GitHub
parent 6f31717c47
commit 6f3cb059fd
3 changed files with 19 additions and 0 deletions

View file

@ -139,6 +139,10 @@ timeval_from_double(double d, struct timeval *tv)
{
tv->tv_sec = floor(d);
tv->tv_usec = fmod(d, 1.0) * 1000000.0;
/* Don't disable the timer if the computation above rounds down to zero. */
if (d > 0.0 && tv->tv_sec == 0 && tv->tv_usec == 0) {
tv->tv_usec = 1;
}
}
Py_LOCAL_INLINE(double)