[Python-checkins] bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)
Victor Stinner
webhook-mailer at python.org
Tue Jan 7 09:00:06 EST 2020
https://github.com/python/cpython/commit/5b23f7618d434f3000bde482233c8642a6eb2c67
commit: 5b23f7618d434f3000bde482233c8642a6eb2c67
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-01-07T15:00:02+01:00
summary:
bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)
The select.epoll.unregister() method no longer ignores the EBADF
error.
files:
A Misc/NEWS.d/next/Library/2020-01-07-01-02-44.bpo-39239.r7vecs.rst
M Doc/library/select.rst
M Doc/whatsnew/3.9.rst
M Lib/test/test_epoll.py
M Modules/selectmodule.c
diff --git a/Doc/library/select.rst b/Doc/library/select.rst
index 8f5a2cea9257c..bb2809580d040 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 ff0fc24f317d4..46774c28c6aed 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 8ac0f31d8051c..10f148fe5cdb4 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -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")
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 0000000000000..2a1c9290869c1
--- /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 79cc1b265559b..7c6d7e4a15e96 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:
More information about the Python-checkins
mailing list