]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40280: select: Use NULL for empty fdset (GH-31865)
authorChristian Heimes <christian@python.org>
Mon, 14 Mar 2022 13:40:28 +0000 (15:40 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Mar 2022 13:40:28 +0000 (14:40 +0100)
wasm32-emscripten does not support exceptfds and requires NULL. Python
now passes NULL instead of a fdset pointer when the input list is empty.
This works fine on all platforms and might even be a tiny bit faster.

Lib/test/test_select.py
Misc/NEWS.d/next/Library/2022-03-14-09-26-42.bpo-40280.2-k8TV.rst [new file with mode: 0644]
Modules/selectmodule.c

index cf32cf2f6a6f8b427797315ea3cd52b724a23512..69421fd77558d0e9cb0745f6f1baff47b7064dec 100644 (file)
@@ -46,7 +46,7 @@ class SelectTestCase(unittest.TestCase):
         self.assertIsNot(r, x)
         self.assertIsNot(w, x)
 
-    @unittest.skipUnless(hasattr(os, 'popen'), "need os.popen()")
+    @support.requires_fork()
     def test_select(self):
         code = textwrap.dedent('''
             import time
diff --git a/Misc/NEWS.d/next/Library/2022-03-14-09-26-42.bpo-40280.2-k8TV.rst b/Misc/NEWS.d/next/Library/2022-03-14-09-26-42.bpo-40280.2-k8TV.rst
new file mode 100644 (file)
index 0000000..f27c968
--- /dev/null
@@ -0,0 +1 @@
+:func:`select.select` now passes ``NULL`` to ``select`` for each empty fdset.
index 1a5a63249c7b8a2ef3de2e2b4198488650f5137d..5c36eaaedeb70b2d62da4e4c42b12cdc503fb85c 100644 (file)
@@ -330,7 +330,12 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
     do {
         Py_BEGIN_ALLOW_THREADS
         errno = 0;
-        n = select(max, &ifdset, &ofdset, &efdset, tvp);
+        n = select(
+            max,
+            imax ? &ifdset : NULL,
+            omax ? &ofdset : NULL,
+            emax ? &efdset : NULL,
+            tvp);
         Py_END_ALLOW_THREADS
 
         if (errno != EINTR)