Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/library/select.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ Edge and Level Trigger Polling (epoll) Objects

Remove a registered file descriptor from the epoll object.

.. versionchanged:: 3.9
The method no longer ignores the :data:`~errno.EBADF` error.


.. method:: epoll.poll(timeout=None, maxevents=-1)

Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ Changes in the Python API
* The :mod:`venv` activation scripts no longer special-case when
``__VENV_PROMPT__`` is set to ``""``.

* The :meth:`select.epoll.unregister` method no longer ignores the
:data:`~errno.EBADF` error.
(Contributed by Victor Stinner in :issue:`39239`.)


CPython bytecode changes
------------------------
Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_epoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def test_unregister_closed(self):
self.assertFalse(then - now > 0.01)

server.close()
ep.unregister(fd)

with self.assertRaises(OSError) as cm:
ep.unregister(fd)
self.assertEqual(cm.exception.errno, errno.EBADF)

def test_close(self):
open_file = open(__file__, "rb")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The :meth:`select.epoll.unregister` method no longer ignores the
:data:`~errno.EBADF` error.
5 changes: 0 additions & 5 deletions Modules/selectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,11 +1447,6 @@ pyepoll_internal_ctl(int epfd, int op, int fd, unsigned int events)
* though this argument is ignored. */
Py_BEGIN_ALLOW_THREADS
result = epoll_ctl(epfd, op, fd, &ev);
if (errno == EBADF) {
/* fd already closed */
result = 0;
errno = 0;
}
Py_END_ALLOW_THREADS
break;
default:
Expand Down