From 729780a810bbcb12b245a1b652302a601fc9f6fd Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 30 Jun 2017 10:01:05 +0200 Subject: bpo-30807: signal.setitimer() may disable the timer by mistake (#2493) * bpo-30807: signal.setitimer() may disable the timer by mistake * Add NEWS blurb --- Modules/signalmodule.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Modules/signalmodule.c') diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index cbf0d54305..b511d17c38 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -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) -- cgit v1.2.1