diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -145,6 +145,11 @@ time_sleep(PyObject *self, PyObject *arg 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 -1; + } if (floatsleep(secs) != 0) return NULL; Py_INCREF(Py_None);