summaryrefslogtreecommitdiff
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 22:00:25 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 22:00:25 +0200
commit7f53a5027d9e290dc288ed2d931ea4c383c416af (patch)
treee5ff2744cfd2f6f6521eae76b246e4d5cc560f70 /Modules/timemodule.c
parent5351a1f956d4d03bea00b650a0333b8eebd2b799 (diff)
downloadcpython-git-7f53a5027d9e290dc288ed2d931ea4c383c416af.tar.gz
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.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c5
1 files changed, 5 insertions, 0 deletions
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);