diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-07 15:00:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-07 15:00:02 +0100 |
commit | 5b23f7618d434f3000bde482233c8642a6eb2c67 (patch) | |
tree | 508eda874d33efba8977a29e1ac4447b4d3a8cb1 | |
parent | 10ac0cded26d91c3468e5e5a87cecad7fc0bcebd (diff) | |
download | cpython-git-5b23f7618d434f3000bde482233c8642a6eb2c67.tar.gz |
bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)
The select.epoll.unregister() method no longer ignores the EBADF
error.
-rw-r--r-- | Doc/library/select.rst | 3 | ||||
-rw-r--r-- | Doc/whatsnew/3.9.rst | 4 | ||||
-rw-r--r-- | Lib/test/test_epoll.py | 5 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-01-07-01-02-44.bpo-39239.r7vecs.rst | 2 | ||||
-rw-r--r-- | Modules/selectmodule.c | 5 |
5 files changed, 13 insertions, 6 deletions
diff --git a/Doc/library/select.rst b/Doc/library/select.rst index 8f5a2cea92..bb2809580d 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -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) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index ff0fc24f31..46774c28c6 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -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 ------------------------ diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py index 8ac0f31d80..10f148fe5c 100644 --- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -225,7 +225,10 @@ class TestEPoll(unittest.TestCase): 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") diff --git a/Misc/NEWS.d/next/Library/2020-01-07-01-02-44.bpo-39239.r7vecs.rst b/Misc/NEWS.d/next/Library/2020-01-07-01-02-44.bpo-39239.r7vecs.rst new file mode 100644 index 0000000000..2a1c929086 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-01-07-01-02-44.bpo-39239.r7vecs.rst @@ -0,0 +1,2 @@ +The :meth:`select.epoll.unregister` method no longer ignores the +:data:`~errno.EBADF` error. diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 79cc1b2655..7c6d7e4a15 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -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: |