[Python-checkins] cpython: Issue #11757: select.select() now raises ValueError when a negative timeout
antoine.pitrou
python-checkins at python.org
Sat Apr 9 23:50:02 CEST 2011
http://hg.python.org/cpython/rev/3982be773b54
changeset: 69224:3982be773b54
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Apr 09 23:49:58 2011 +0200
summary:
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.
files:
Lib/test/test_select.py | 1 +
Misc/NEWS | 4 ++++
Modules/selectmodule.c | 5 +++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -20,6 +20,7 @@
self.assertRaises(TypeError, select.select, [self.Nope()], [], [])
self.assertRaises(TypeError, select.select, [self.Almost()], [], [])
self.assertRaises(TypeError, select.select, [], [], [], "not a number")
+ self.assertRaises(ValueError, select.select, [], [], [], -1)
def test_returned_list_identity(self):
# See issue #8329
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -103,6 +103,10 @@
Library
-------
+- 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.
+
- Issue #7311: fix html.parser to accept non-ASCII attribute values.
- Issue #11605: email.parser.BytesFeedParser was incorrectly converting multipart
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list