bpo-40280: select: Use NULL for empty fdset (GH-31865)

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.
This commit is contained in:
Christian Heimes 2022-03-14 15:40:28 +02:00 committed by GitHub
parent 23abae621f
commit f00ced8396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View 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

View File

@ -0,0 +1 @@
:func:`select.select` now passes ``NULL`` to ``select`` for each empty fdset.

View 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)