diff Modules/selectmodule.c @ 69224:3982be773b54

Issue #11757: select.select() now raises ValueError when a negative timeout is passed (previously, a select.error with EINVAL would be raised). Patch by Charles-François Natali.
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 09 Apr 2011 23:49:58 +0200
parents 3c9232a684ae
children ddb8a29a6bc5
line wrap: on
line diff
--- a/Modules/selectmodule.c	Sat Apr 09 13:00:17 2011 -0700
+++ b/Modules/selectmodule.c	Sat Apr 09 23:49:58 2011 +0200
@@ -234,6 +234,11 @@
                             "timeout period too long");
             return NULL;
         }
+        if (timeout < 0) {
+            PyErr_SetString(PyExc_ValueError,
+                        "timeout must be non-negative");
+            return NULL;
+        }
         seconds = (long)timeout;
         timeout = timeout - (double)seconds;
         tv.tv_sec = seconds;