diff options
Diffstat (limited to 'Modules/clinic/selectmodule.c.h')
-rw-r--r-- | Modules/clinic/selectmodule.c.h | 119 |
1 files changed, 103 insertions, 16 deletions
diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index c2ef26f..9015816 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -512,14 +512,45 @@ select_epoll(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sizehint", "flags", NULL}; - static _PyArg_Parser _parser = {"|ii:epoll", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "epoll", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; int sizehint = -1; int flags = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &sizehint, &flags)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + if (PyFloat_Check(fastargs[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + sizehint = _PyLong_AsInt(fastargs[0]); + if (sizehint == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(fastargs[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = select_epoll_impl(type, sizehint, flags); exit: @@ -638,14 +669,32 @@ select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "eventmask", NULL}; - static _PyArg_Parser _parser = {"O&|I:register", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "register", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; int fd; unsigned int eventmask = EPOLLIN | EPOLLPRI | EPOLLOUT; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd, &eventmask)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + eventmask = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (eventmask == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = select_epoll_register_impl(self, fd, eventmask); exit: @@ -679,12 +728,25 @@ select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "eventmask", NULL}; - static _PyArg_Parser _parser = {"O&I:modify", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "modify", 0}; + PyObject *argsbuf[2]; int fd; unsigned int eventmask; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd, &eventmask)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + eventmask = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (eventmask == (unsigned int)-1 && PyErr_Occurred()) { goto exit; } return_value = select_epoll_modify_impl(self, fd, eventmask); @@ -717,11 +779,15 @@ select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"O&:unregister", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "unregister", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } return_value = select_epoll_unregister_impl(self, fd); @@ -761,14 +827,35 @@ select_epoll_poll(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"timeout", "maxevents", NULL}; - static _PyArg_Parser _parser = {"|Oi:poll", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "poll", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *timeout_obj = Py_None; int maxevents = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &timeout_obj, &maxevents)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + timeout_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + maxevents = _PyLong_AsInt(args[1]); + if (maxevents == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = select_epoll_poll_impl(self, timeout_obj, maxevents); exit: @@ -1128,4 +1215,4 @@ exit: #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=3e40b33a3294d03d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=03041f3d09b04a3d input=a9049054013a1b77]*/ |