Commit 131a6414 authored by Antoine Pitrou's avatar Antoine Pitrou

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.
parent c6a726d0
...@@ -20,6 +20,7 @@ class SelectTestCase(unittest.TestCase): ...@@ -20,6 +20,7 @@ class SelectTestCase(unittest.TestCase):
self.assertRaises(TypeError, select.select, [self.Nope()], [], []) self.assertRaises(TypeError, select.select, [self.Nope()], [], [])
self.assertRaises(TypeError, select.select, [self.Almost()], [], []) self.assertRaises(TypeError, select.select, [self.Almost()], [], [])
self.assertRaises(TypeError, select.select, [], [], [], "not a number") self.assertRaises(TypeError, select.select, [], [], [], "not a number")
self.assertRaises(ValueError, select.select, [], [], [], -1)
def test_returned_list_identity(self): def test_returned_list_identity(self):
# See issue #8329 # See issue #8329
......
...@@ -103,6 +103,10 @@ Core and Builtins ...@@ -103,6 +103,10 @@ Core and Builtins
Library 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 #7311: fix html.parser to accept non-ASCII attribute values.
- Issue #11605: email.parser.BytesFeedParser was incorrectly converting multipart - Issue #11605: email.parser.BytesFeedParser was incorrectly converting multipart
......
...@@ -234,6 +234,11 @@ select_select(PyObject *self, PyObject *args) ...@@ -234,6 +234,11 @@ select_select(PyObject *self, PyObject *args)
"timeout period too long"); "timeout period too long");
return NULL; return NULL;
} }
if (timeout < 0) {
PyErr_SetString(PyExc_ValueError,
"timeout must be non-negative");
return NULL;
}
seconds = (long)timeout; seconds = (long)timeout;
timeout = timeout - (double)seconds; timeout = timeout - (double)seconds;
tv.tv_sec = seconds; tv.tv_sec = seconds;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment