From: Neal Norwitz Date: Thu, 3 Nov 2005 05:00:25 +0000 (+0000) Subject: Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint X-Git-Tag: v2.5a0~1195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f46bbf7814476de107d16f67561d611d900f5a3;p=thirdparty%2FPython%2Fcpython.git Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint Need to check return result of PyInt_AsLong() Will backport. --- diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py index 2ecae6991949..f99c37ff9ee0 100644 --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -168,5 +168,25 @@ def test_poll2(): p.close() print 'Poll test 2 complete' +def test_poll3(): + # test int overflow + print 'Running poll test 3' + pollster = select.poll() + pollster.register(1) + + try: + pollster.poll(1L << 64) + except OverflowError: + pass + else: + print 'Expected OverflowError with excessive timeout' + + x = 2 + 3 + if x != 5: + print 'Overflow must have occurred' + print 'Poll test 3 complete' + + test_poll1() test_poll2() +test_poll3() diff --git a/Misc/NEWS b/Misc/NEWS index 59f165a61e3a..5191c2519b89 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -177,6 +177,8 @@ Core and builtins Extension Modules ----------------- +- Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint + - Bug #1344508, Fix UNIX mmap leaking file descriptors - Patch #1338314, Bug #1336623: fix tarfile so it can extract diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 81c9e3cd9847..ed2ea8197c5a 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -470,6 +470,8 @@ poll_poll(pollObject *self, PyObject *args) return NULL; timeout = PyInt_AsLong(tout); Py_DECREF(tout); + if (timeout == -1 && PyErr_Occurred()) + return NULL; } /* Ensure the ufd array is up to date */