diff options
author | doko <doko@ubuntu.com> | 2017-01-31 13:35:56 +0100 |
---|---|---|
committer | doko <doko@ubuntu.com> | 2017-01-31 13:35:56 +0100 |
commit | b23072b8814146d3a76eb752fd7526eb1575e7cc (patch) | |
tree | cf13a75e5570561a10bf68c2c451e9271229a3be /Modules/selectmodule.c | |
parent | e0cb38ac4330d5e09b5e21c74c5d5e453af99a4f (diff) | |
parent | ccd19e48ec9d557231bf923c338be0e7509a51d3 (diff) | |
download | cpython-b23072b8814146d3a76eb752fd7526eb1575e7cc.tar.gz |
merge 3.6
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 47da49399f..8bdf3359d4 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -353,7 +353,7 @@ update_ufd_array(pollObject *self) PyObject *key, *value; struct pollfd *old_ufds = self->ufds; - self->ufd_len = PyDict_Size(self->dict); + self->ufd_len = PyDict_GET_SIZE(self->dict); PyMem_RESIZE(self->ufds, struct pollfd, self->ufd_len); if (self->ufds == NULL) { self->ufds = old_ufds; @@ -431,8 +431,7 @@ poll_register(pollObject *self, PyObject *args) self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(poll_modify_doc, @@ -479,8 +478,7 @@ poll_modify(pollObject *self, PyObject *args) self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -513,8 +511,7 @@ poll_unregister(pollObject *self, PyObject *o) Py_DECREF(key); self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(poll_poll_doc, @@ -1252,7 +1249,7 @@ pyepoll_internal_close(pyEpoll_Object *self) } 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 +1261,10 @@ newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) if (fd == -1) { Py_BEGIN_ALLOW_THREADS #ifdef HAVE_EPOLL_CREATE1 - flags |= EPOLL_CLOEXEC; - if (flags) - self->epfd = epoll_create1(flags); - else -#endif + self->epfd = epoll_create1(EPOLL_CLOEXEC); +#else self->epfd = epoll_create(sizehint); +#endif Py_END_ALLOW_THREADS } else { @@ -1305,8 +1300,12 @@ pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_ValueError, "negative sizehint"); return NULL; } + if (flags && flags != EPOLL_CLOEXEC) { + PyErr_SetString(PyExc_OSError, "invalid flags"); + return NULL; + } - return newPyEpoll_Object(type, sizehint, flags, -1); + return newPyEpoll_Object(type, sizehint, -1); } @@ -1364,7 +1363,7 @@ pyepoll_fromfd(PyObject *cls, PyObject *args) if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) return NULL; - return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, 0, fd); + return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, fd); } PyDoc_STRVAR(pyepoll_fromfd_doc, |