From afda4ba3b616093a39b92ac5a9c4e5de3b9b4078 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Thu, 17 Oct 2019 20:57:12 +0200 Subject: [PATCH 1/4] Document that select() accepts iterables, not just sequences --- Doc/library/select.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/select.rst b/Doc/library/select.rst index 8f5a2cea9257cc2..39622aadf3fa540 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -117,7 +117,7 @@ The module defines the following: .. function:: select(rlist, wlist, xlist[, timeout]) This is a straightforward interface to the Unix :c:func:`select` system call. - The first three arguments are sequences of 'waitable objects': either + The first three arguments are iterables of 'waitable objects': either integers representing file descriptors or objects with a parameterless method named :meth:`~io.IOBase.fileno` returning such an integer: @@ -126,7 +126,7 @@ The module defines the following: * *xlist*: wait for an "exceptional condition" (see the manual page for what your system considers such a condition) - Empty sequences are allowed, but acceptance of three empty sequences is + Empty iterables are allowed, but acceptance of three empty iterables is platform-dependent. (It is known to work on Unix but not on Windows.) The optional *timeout* argument specifies a time-out as a floating point number in seconds. When the *timeout* argument is omitted the function blocks until @@ -141,7 +141,7 @@ The module defines the following: single: socket() (in module socket) single: popen() (in module os) - Among the acceptable object types in the sequences are Python :term:`file + Among the acceptable object types in the iterables are Python :term:`file objects ` (e.g. ``sys.stdin``, or objects returned by :func:`open` or :func:`os.popen`), socket objects returned by :func:`socket.socket`. You may also define a :dfn:`wrapper` class yourself, From 76443320d2d10706f05bef5f4b4b55247f0565ff Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 22 Oct 2019 18:00:14 +0200 Subject: [PATCH 2/4] select: Replace sequences/lists with iterables in more places --- Modules/selectmodule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 79cc1b265559be5..90c785ece2aa82e 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -232,11 +232,11 @@ select.select Wait until one or more file descriptors are ready for some kind of I/O. -The first three arguments are sequences of file descriptors to be waited for: +The first three arguments are iterables of file descriptors to be waited for: rlist -- wait until ready for reading wlist -- wait until ready for writing xlist -- wait for an "exceptional condition" -If only one kind of condition is required, pass [] for the other lists. +If only one kind of condition is required, pass empty iterables for the other lists. A file descriptor is either a socket or file object, or a small integer gotten from a fileno() method call on one of those. @@ -313,7 +313,7 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, } #endif /* SELECT_USES_HEAP */ - /* Convert sequences to fd_sets, and get maximum fd number + /* Convert iterables to fd_sets, and get maximum fd number * propagates the Python exception set in seq2set() */ rfd2obj[0].sentinel = -1; From 137729dd3b2b56dd4788dd4d41d9c1f9cac5c8ae Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 23 Oct 2019 03:07:09 +0200 Subject: [PATCH 3/4] Rerun Argument Clinic on the select module --- Modules/clinic/selectmodule.c.h | 6 +++--- Modules/selectmodule.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index 670af6a3d8de6cc..d579d5e5dca76fb 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -8,11 +8,11 @@ PyDoc_STRVAR(select_select__doc__, "\n" "Wait until one or more file descriptors are ready for some kind of I/O.\n" "\n" -"The first three arguments are sequences of file descriptors to be waited for:\n" +"The first three arguments are iterables of file descriptors to be waited for:\n" "rlist -- wait until ready for reading\n" "wlist -- wait until ready for writing\n" "xlist -- wait for an \"exceptional condition\"\n" -"If only one kind of condition is required, pass [] for the other lists.\n" +"If only one kind of condition is required, pass empty iterables for the other lists.\n" "\n" "A file descriptor is either a socket or file object, or a small integer\n" "gotten from a fileno() method call on one of those.\n" @@ -1215,4 +1215,4 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=26bb05e5fba2bfd1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cd816b2887de18c1 input=a9049054013a1b77]*/ diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 90c785ece2aa82e..1f1ce47f37b7e7b 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -257,7 +257,7 @@ descriptors can be used. static PyObject * select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, PyObject *xlist, PyObject *timeout_obj) -/*[clinic end generated code: output=2b3cfa824f7ae4cf input=177e72184352df25]*/ +/*[clinic end generated code: output=2b3cfa824f7ae4cf input=fc219cac9803bb5f]*/ { #ifdef SELECT_USES_HEAP pylist *rfd2obj, *wfd2obj, *efd2obj; From 2a68bdebadc3afc7e8b896fdd92d682ede0bbb45 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Fri, 17 Apr 2020 00:21:39 +0200 Subject: [PATCH 4/4] Revert a docstring change It's been determined to be good the way it was. --- Modules/clinic/selectmodule.c.h | 4 ++-- Modules/selectmodule.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index d579d5e5dca76fb..888054b29eba285 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -12,7 +12,7 @@ PyDoc_STRVAR(select_select__doc__, "rlist -- wait until ready for reading\n" "wlist -- wait until ready for writing\n" "xlist -- wait for an \"exceptional condition\"\n" -"If only one kind of condition is required, pass empty iterables for the other lists.\n" +"If only one kind of condition is required, pass [] for the other lists.\n" "\n" "A file descriptor is either a socket or file object, or a small integer\n" "gotten from a fileno() method call on one of those.\n" @@ -1215,4 +1215,4 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=cd816b2887de18c1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=029f23fbe000d7f7 input=a9049054013a1b77]*/ diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 1f1ce47f37b7e7b..471ffc1f9928e86 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -236,7 +236,7 @@ The first three arguments are iterables of file descriptors to be waited for: rlist -- wait until ready for reading wlist -- wait until ready for writing xlist -- wait for an "exceptional condition" -If only one kind of condition is required, pass empty iterables for the other lists. +If only one kind of condition is required, pass [] for the other lists. A file descriptor is either a socket or file object, or a small integer gotten from a fileno() method call on one of those. @@ -257,7 +257,7 @@ descriptors can be used. static PyObject * select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, PyObject *xlist, PyObject *timeout_obj) -/*[clinic end generated code: output=2b3cfa824f7ae4cf input=fc219cac9803bb5f]*/ +/*[clinic end generated code: output=2b3cfa824f7ae4cf input=e467f5d68033de00]*/ { #ifdef SELECT_USES_HEAP pylist *rfd2obj, *wfd2obj, *efd2obj;