From 7f53a5027d9e290dc288ed2d931ea4c383c416af Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 5 Jul 2011 22:00:25 +0200 Subject: Issue #12459: time.sleep() now raises a ValueError if the sleep length is negative, instead of an infinite sleep on Windows or raising an IOError on Linux for example, to have the same behaviour on all platforms. --- Modules/timemodule.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Modules/timemodule.c') diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 636d4adcf0..4dc82a0310 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -141,6 +141,11 @@ time_sleep(PyObject *self, PyObject *args) double secs; if (!PyArg_ParseTuple(args, "d:sleep", &secs)) return NULL; + if (secs < 0) { + PyErr_SetString(PyExc_ValueError, + "sleep length must be non-negative"); + return NULL; + } if (floatsleep(secs) != 0) return NULL; Py_INCREF(Py_None); -- cgit v1.2.1