bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)

The select.epoll.unregister() method no longer ignores the EBADF
error.
This commit is contained in:
Victor Stinner 2020-01-07 15:00:02 +01:00 committed by GitHub
parent 10ac0cded2
commit 5b23f7618d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 6 deletions

View File

@ -355,6 +355,9 @@ Edge and Level Trigger Polling (epoll) Objects
Remove a registered file descriptor from the epoll object. 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) .. method:: epoll.poll(timeout=None, maxevents=-1)

View File

@ -382,6 +382,10 @@ Changes in the Python API
* The :mod:`venv` activation scripts no longer special-case when * The :mod:`venv` activation scripts no longer special-case when
``__VENV_PROMPT__`` is set to ``""``. ``__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 CPython bytecode changes
------------------------ ------------------------

View File

@ -225,7 +225,10 @@ class TestEPoll(unittest.TestCase):
self.assertFalse(then - now > 0.01) self.assertFalse(then - now > 0.01)
server.close() 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): def test_close(self):
open_file = open(__file__, "rb") open_file = open(__file__, "rb")

View File

@ -0,0 +1,2 @@
The :meth:`select.epoll.unregister` method no longer ignores the
:data:`~errno.EBADF` error.

View File

@ -1447,11 +1447,6 @@ pyepoll_internal_ctl(int epfd, int op, int fd, unsigned int events)
* though this argument is ignored. */ * though this argument is ignored. */
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
result = epoll_ctl(epfd, op, fd, &ev); result = epoll_ctl(epfd, op, fd, &ev);
if (errno == EBADF) {
/* fd already closed */
result = 0;
errno = 0;
}
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
break; break;
default: default: