]> granicus.if.org Git - python/commitdiff
remove a optimization that resulted in unexpected behavior #8929
authorBenjamin Peterson <benjamin@python.org>
Tue, 6 Apr 2010 21:50:00 +0000 (21:50 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 6 Apr 2010 21:50:00 +0000 (21:50 +0000)
Lib/test/test_select.py
Misc/NEWS
Modules/selectmodule.c

index fd7c8d0c5e4ea0f3e741d117abe1b80c034dcd43..647d71ef20946c7dbe2134acb6ba9ad23eb59fa2 100644 (file)
@@ -21,6 +21,13 @@ class SelectTestCase(unittest.TestCase):
         self.assertRaises(TypeError, select.select, [self.Almost()], [], [])
         self.assertRaises(TypeError, select.select, [], [], [], "not a number")
 
+    def test_returned_list_identity(self):
+        # See issue #8329
+        r, w, x = select.select([], [], [], 1)
+        self.assertIsNot(r, w)
+        self.assertIsNot(r, x)
+        self.assertIsNot(w, x)
+
     def test_select(self):
         cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
         p = os.popen(cmd, 'r')
index 8b415be3b3c1ee092bc2447a8f340f1578fed985..7b823725a3dd70afc1224da78ea54432f7e56d2c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.7 beta 1?
 Core and Builtins
 -----------------
 
+- Issue #8329: Don't return the same lists from select.select when no fds are
+  changed.
+
 - Issue #8259: 1L << (2**31) no longer produces an 'outrageous shift error'
   on 64-bit machines.  The shift count for either left or right shift is
   permitted to be up to sys.maxsize.
index aae08d5b817142c2bb2c5db10d9c550b2c9770ed..5f862d73bb03ebbc716ccb3ba9f7a2df72598a0b 100644 (file)
@@ -287,14 +287,6 @@ select_select(PyObject *self, PyObject *args)
                PyErr_SetFromErrno(SelectError);
        }
 #endif
-       else if (n == 0) {
-                /* optimization */
-               ifdlist = PyList_New(0);
-               if (ifdlist) {
-                       ret = PyTuple_Pack(3, ifdlist, ifdlist, ifdlist);
-                       Py_DECREF(ifdlist);
-               }
-       }
        else {
                /* any of these three calls can raise an exception.  it's more
                   convenient to test for this after all three calls... but