]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport (with output/test_poll):
authorNeal Norwitz <nnorwitz@gmail.com>
Thu, 3 Nov 2005 05:11:17 +0000 (05:11 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Thu, 3 Nov 2005 05:11:17 +0000 (05:11 +0000)
Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint
Need to check return result of PyInt_AsLong()

Lib/test/output/test_poll
Lib/test/test_poll.py
Misc/NEWS
Modules/selectmodule.c

index 99d6fa7aa790b0b38429157a47f8d4e595dbe8f2..ca61d377de5d42e10e23b3b7cc443c99c5f3349b 100644 (file)
@@ -15,3 +15,5 @@ Running poll test 1
 Poll test 1 complete
 Running poll test 2
 Poll test 2 complete
+Running poll test 3
+Poll test 3 complete
index 2ecae6991949e002e42bfadaba7da2c2d2e96a46..f99c37ff9ee0cda14cc573a137bbd9aaeb07020c 100644 (file)
@@ -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()
index ae962c9227f70168bc8e5b50669fb561be3422ee..ba21bfd435b90497b0a849b948aa10a501372aa2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -151,6 +151,8 @@ Core and builtins
 Extension Modules
 -----------------
 
+- Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint
+
 - Fix memory leak in posix.access().
 
 - Patch #1213831: Fix typo in unicodedata._getcode.
index 81c9e3cd98478261f63f6dcd480584cdbecbca66..ed2ea8197c5a934040c2747b6e77d2b99c3d6870 100644 (file)
@@ -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 */