Skip to content

Commit f00ced8

Browse files
authored
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.
1 parent 23abae6 commit f00ced8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Lib/test/test_select.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_returned_list_identity(self):
4646
self.assertIsNot(r, x)
4747
self.assertIsNot(w, x)
4848

49-
@unittest.skipUnless(hasattr(os, 'popen'), "need os.popen()")
49+
@support.requires_fork()
5050
def test_select(self):
5151
code = textwrap.dedent('''
5252
import time
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`select.select` now passes ``NULL`` to ``select`` for each empty fdset.

Modules/selectmodule.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
330330
do {
331331
Py_BEGIN_ALLOW_THREADS
332332
errno = 0;
333-
n = select(max, &ifdset, &ofdset, &efdset, tvp);
333+
n = select(
334+
max,
335+
imax ? &ifdset : NULL,
336+
omax ? &ofdset : NULL,
337+
emax ? &efdset : NULL,
338+
tvp);
334339
Py_END_ALLOW_THREADS
335340

336341
if (errno != EINTR)

0 commit comments

Comments
 (0)