cpython: ac24e5c2fd3e (original) (raw)
Mercurial > cpython
changeset 104086:ac24e5c2fd3e
Issue #20100: Simplify newPyEpoll_Object() EPOLL_CLOEXEC is the only value that can be passed to epoll_create1() and we are passing EPOLL_CLOEXEC unconditionally since Python 3.4. [#20100]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Mon, 26 Sep 2016 23:30:41 +0300 |
parents | f91650739061 |
children | 9fc2b6dba9c2 |
files | Lib/test/test_epoll.py Modules/selectmodule.c |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-)[+] [-] Lib/test/test_epoll.py 2 Modules/selectmodule.c 18 |
line wrap: on
line diff
--- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -76,6 +76,8 @@ class TestEPoll(unittest.TestCase): self.assertRaises(ValueError, ep.fileno) if hasattr(select, "EPOLL_CLOEXEC"): select.epoll(select.EPOLL_CLOEXEC).close()
select.epoll(flags=select.EPOLL_CLOEXEC).close()[](#l1.7)
select.epoll(flags=0).close()[](#l1.8) self.assertRaises(OSError, select.epoll, flags=12356)[](#l1.9)
--- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1252,7 +1252,7 @@ pyepoll_internal_close(pyEpoll_Object *s } static PyObject * -newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) +newPyEpoll_Object(PyTypeObject *type, int sizehint, SOCKET fd) { pyEpoll_Object *self; @@ -1264,12 +1264,10 @@ newPyEpoll_Object(PyTypeObject *type, in if (fd == -1) { Py_BEGIN_ALLOW_THREADS #ifdef HAVE_EPOLL_CREATE1
flags |= EPOLL_CLOEXEC;[](#l2.16)
if (flags)[](#l2.17)
self->epfd = epoll_create1(flags);[](#l2.18)
else[](#l2.19)
self->epfd = epoll_create1(EPOLL_CLOEXEC);[](#l2.20)
self->epfd = epoll_create(sizehint);[](#l2.22)
} else { @@ -1305,8 +1303,12 @@ pyepoll_new(PyTypeObject *type, PyObject PyErr_SetString(PyExc_ValueError, "negative sizehint"); return NULL; }self->epfd = epoll_create(sizehint);[](#l2.24) Py_END_ALLOW_THREADS[](#l2.25)
- if (flags && flags != EPOLL_CLOEXEC) {
PyErr_SetString(PyExc_OSError, "invalid flags");[](#l2.33)
return NULL;[](#l2.34)
- }
} @@ -1364,7 +1366,7 @@ pyepoll_fromfd(PyObject *cls, PyObject * if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) return NULL;