diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/clinic | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/clinic')
52 files changed, 20288 insertions, 20288 deletions
diff --git a/contrib/tools/python3/src/Modules/clinic/_abc.c.h b/contrib/tools/python3/src/Modules/clinic/_abc.c.h index 62c6552ba6..33eb75d731 100644 --- a/contrib/tools/python3/src/Modules/clinic/_abc.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_abc.c.h @@ -53,7 +53,7 @@ PyDoc_STRVAR(_abc__abc_register__doc__, "Internal ABC helper for subclasss registration. Should be never used outside abc module."); #define _ABC__ABC_REGISTER_METHODDEF \ - {"_abc_register", (PyCFunction)(void(*)(void))_abc__abc_register, METH_FASTCALL, _abc__abc_register__doc__}, + {"_abc_register", (PyCFunction)(void(*)(void))_abc__abc_register, METH_FASTCALL, _abc__abc_register__doc__}, static PyObject * _abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass); @@ -65,11 +65,11 @@ _abc__abc_register(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *self; PyObject *subclass; - if (!_PyArg_CheckPositional("_abc_register", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("_abc_register", nargs, 2, 2)) { goto exit; } - self = args[0]; - subclass = args[1]; + self = args[0]; + subclass = args[1]; return_value = _abc__abc_register_impl(module, self, subclass); exit: @@ -83,7 +83,7 @@ PyDoc_STRVAR(_abc__abc_instancecheck__doc__, "Internal ABC helper for instance checks. Should be never used outside abc module."); #define _ABC__ABC_INSTANCECHECK_METHODDEF \ - {"_abc_instancecheck", (PyCFunction)(void(*)(void))_abc__abc_instancecheck, METH_FASTCALL, _abc__abc_instancecheck__doc__}, + {"_abc_instancecheck", (PyCFunction)(void(*)(void))_abc__abc_instancecheck, METH_FASTCALL, _abc__abc_instancecheck__doc__}, static PyObject * _abc__abc_instancecheck_impl(PyObject *module, PyObject *self, @@ -96,11 +96,11 @@ _abc__abc_instancecheck(PyObject *module, PyObject *const *args, Py_ssize_t narg PyObject *self; PyObject *instance; - if (!_PyArg_CheckPositional("_abc_instancecheck", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("_abc_instancecheck", nargs, 2, 2)) { goto exit; } - self = args[0]; - instance = args[1]; + self = args[0]; + instance = args[1]; return_value = _abc__abc_instancecheck_impl(module, self, instance); exit: @@ -114,7 +114,7 @@ PyDoc_STRVAR(_abc__abc_subclasscheck__doc__, "Internal ABC helper for subclasss checks. Should be never used outside abc module."); #define _ABC__ABC_SUBCLASSCHECK_METHODDEF \ - {"_abc_subclasscheck", (PyCFunction)(void(*)(void))_abc__abc_subclasscheck, METH_FASTCALL, _abc__abc_subclasscheck__doc__}, + {"_abc_subclasscheck", (PyCFunction)(void(*)(void))_abc__abc_subclasscheck, METH_FASTCALL, _abc__abc_subclasscheck__doc__}, static PyObject * _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self, @@ -127,11 +127,11 @@ _abc__abc_subclasscheck(PyObject *module, PyObject *const *args, Py_ssize_t narg PyObject *self; PyObject *subclass; - if (!_PyArg_CheckPositional("_abc_subclasscheck", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("_abc_subclasscheck", nargs, 2, 2)) { goto exit; } - self = args[0]; - subclass = args[1]; + self = args[0]; + subclass = args[1]; return_value = _abc__abc_subclasscheck_impl(module, self, subclass); exit: @@ -159,4 +159,4 @@ _abc_get_cache_token(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _abc_get_cache_token_impl(module); } -/*[clinic end generated code: output=2544b4b5ae50a089 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2544b4b5ae50a089 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_asynciomodule.c.h b/contrib/tools/python3/src/Modules/clinic/_asynciomodule.c.h index a071efc1e2..04652f165c 100644 --- a/contrib/tools/python3/src/Modules/clinic/_asynciomodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_asynciomodule.c.h @@ -27,22 +27,22 @@ _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"loop", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Future", 0}; - PyObject *argsbuf[1]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "Future", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *loop = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - loop = fastargs[0]; -skip_optional_kwonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + loop = fastargs[0]; +skip_optional_kwonly: return_value = _asyncio_Future___init___impl((FutureObj *)self, loop); exit: @@ -119,7 +119,7 @@ PyDoc_STRVAR(_asyncio_Future_set_exception__doc__, {"set_exception", (PyCFunction)_asyncio_Future_set_exception, METH_O, _asyncio_Future_set_exception__doc__}, PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__, -"add_done_callback($self, fn, /, *, context=<unrepresentable>)\n" +"add_done_callback($self, fn, /, *, context=<unrepresentable>)\n" "--\n" "\n" "Add a callback to be run when the future becomes done.\n" @@ -129,7 +129,7 @@ PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__, "scheduled with call_soon."); #define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \ - {"add_done_callback", (PyCFunction)(void(*)(void))_asyncio_Future_add_done_callback, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__}, + {"add_done_callback", (PyCFunction)(void(*)(void))_asyncio_Future_add_done_callback, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__}, static PyObject * _asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn, @@ -140,22 +140,22 @@ _asyncio_Future_add_done_callback(FutureObj *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "context", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "add_done_callback", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "add_done_callback", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *fn; PyObject *context = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - fn = args[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - context = args[1]; -skip_optional_kwonly: + fn = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + context = args[1]; +skip_optional_kwonly: return_value = _asyncio_Future_add_done_callback_impl(self, fn, context); exit: @@ -174,7 +174,7 @@ PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__, {"remove_done_callback", (PyCFunction)_asyncio_Future_remove_done_callback, METH_O, _asyncio_Future_remove_done_callback__doc__}, PyDoc_STRVAR(_asyncio_Future_cancel__doc__, -"cancel($self, /, msg=None)\n" +"cancel($self, /, msg=None)\n" "--\n" "\n" "Cancel the future and schedule callbacks.\n" @@ -184,34 +184,34 @@ PyDoc_STRVAR(_asyncio_Future_cancel__doc__, "return True."); #define _ASYNCIO_FUTURE_CANCEL_METHODDEF \ - {"cancel", (PyCFunction)(void(*)(void))_asyncio_Future_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__}, + {"cancel", (PyCFunction)(void(*)(void))_asyncio_Future_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__}, static PyObject * -_asyncio_Future_cancel_impl(FutureObj *self, PyObject *msg); +_asyncio_Future_cancel_impl(FutureObj *self, PyObject *msg); static PyObject * -_asyncio_Future_cancel(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +_asyncio_Future_cancel(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = {"msg", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *msg = Py_None; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - msg = args[0]; -skip_optional_pos: - return_value = _asyncio_Future_cancel_impl(self, msg); - -exit: - return return_value; + PyObject *return_value = NULL; + static const char * const _keywords[] = {"msg", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *msg = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + msg = args[0]; +skip_optional_pos: + return_value = _asyncio_Future_cancel_impl(self, msg); + +exit: + return return_value; } PyDoc_STRVAR(_asyncio_Future_cancelled__doc__, @@ -271,27 +271,27 @@ _asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored)) return _asyncio_Future_get_loop_impl(self); } -PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__, -"_make_cancelled_error($self, /)\n" -"--\n" -"\n" -"Create the CancelledError to raise if the Future is cancelled.\n" -"\n" -"This should only be called once when handling a cancellation since\n" -"it erases the context exception value."); - -#define _ASYNCIO_FUTURE__MAKE_CANCELLED_ERROR_METHODDEF \ - {"_make_cancelled_error", (PyCFunction)_asyncio_Future__make_cancelled_error, METH_NOARGS, _asyncio_Future__make_cancelled_error__doc__}, - -static PyObject * -_asyncio_Future__make_cancelled_error_impl(FutureObj *self); - -static PyObject * -_asyncio_Future__make_cancelled_error(FutureObj *self, PyObject *Py_UNUSED(ignored)) -{ - return _asyncio_Future__make_cancelled_error_impl(self); -} - +PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__, +"_make_cancelled_error($self, /)\n" +"--\n" +"\n" +"Create the CancelledError to raise if the Future is cancelled.\n" +"\n" +"This should only be called once when handling a cancellation since\n" +"it erases the context exception value."); + +#define _ASYNCIO_FUTURE__MAKE_CANCELLED_ERROR_METHODDEF \ + {"_make_cancelled_error", (PyCFunction)_asyncio_Future__make_cancelled_error, METH_NOARGS, _asyncio_Future__make_cancelled_error__doc__}, + +static PyObject * +_asyncio_Future__make_cancelled_error_impl(FutureObj *self); + +static PyObject * +_asyncio_Future__make_cancelled_error(FutureObj *self, PyObject *Py_UNUSED(ignored)) +{ + return _asyncio_Future__make_cancelled_error_impl(self); +} + PyDoc_STRVAR(_asyncio_Future__repr_info__doc__, "_repr_info($self, /)\n" "--\n" @@ -310,70 +310,70 @@ _asyncio_Future__repr_info(FutureObj *self, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(_asyncio_Task___init____doc__, -"Task(coro, *, loop=None, name=None)\n" +"Task(coro, *, loop=None, name=None)\n" "--\n" "\n" "A coroutine wrapped in a Future."); static int -_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, - PyObject *name); +_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, + PyObject *name); static int _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"coro", "loop", "name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Task", 0}; - PyObject *argsbuf[3]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + static const char * const _keywords[] = {"coro", "loop", "name", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "Task", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *coro; PyObject *loop = Py_None; - PyObject *name = Py_None; + PyObject *name = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - coro = fastargs[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (fastargs[1]) { - loop = fastargs[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - name = fastargs[2]; -skip_optional_kwonly: - return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name); + coro = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + loop = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + name = fastargs[2]; +skip_optional_kwonly: + return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name); exit: return return_value; } -PyDoc_STRVAR(_asyncio_Task__make_cancelled_error__doc__, -"_make_cancelled_error($self, /)\n" +PyDoc_STRVAR(_asyncio_Task__make_cancelled_error__doc__, +"_make_cancelled_error($self, /)\n" "--\n" "\n" -"Create the CancelledError to raise if the Task is cancelled.\n" +"Create the CancelledError to raise if the Task is cancelled.\n" "\n" -"This should only be called once when handling a cancellation since\n" -"it erases the context exception value."); +"This should only be called once when handling a cancellation since\n" +"it erases the context exception value."); -#define _ASYNCIO_TASK__MAKE_CANCELLED_ERROR_METHODDEF \ - {"_make_cancelled_error", (PyCFunction)_asyncio_Task__make_cancelled_error, METH_NOARGS, _asyncio_Task__make_cancelled_error__doc__}, +#define _ASYNCIO_TASK__MAKE_CANCELLED_ERROR_METHODDEF \ + {"_make_cancelled_error", (PyCFunction)_asyncio_Task__make_cancelled_error, METH_NOARGS, _asyncio_Task__make_cancelled_error__doc__}, static PyObject * -_asyncio_Task__make_cancelled_error_impl(TaskObj *self); +_asyncio_Task__make_cancelled_error_impl(TaskObj *self); static PyObject * -_asyncio_Task__make_cancelled_error(TaskObj *self, PyObject *Py_UNUSED(ignored)) +_asyncio_Task__make_cancelled_error(TaskObj *self, PyObject *Py_UNUSED(ignored)) { - return _asyncio_Task__make_cancelled_error_impl(self); + return _asyncio_Task__make_cancelled_error_impl(self); } PyDoc_STRVAR(_asyncio_Task__repr_info__doc__, @@ -394,7 +394,7 @@ _asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(_asyncio_Task_cancel__doc__, -"cancel($self, /, msg=None)\n" +"cancel($self, /, msg=None)\n" "--\n" "\n" "Request that this task cancel itself.\n" @@ -417,34 +417,34 @@ PyDoc_STRVAR(_asyncio_Task_cancel__doc__, "was not called)."); #define _ASYNCIO_TASK_CANCEL_METHODDEF \ - {"cancel", (PyCFunction)(void(*)(void))_asyncio_Task_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__}, + {"cancel", (PyCFunction)(void(*)(void))_asyncio_Task_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__}, static PyObject * -_asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg); +_asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg); static PyObject * -_asyncio_Task_cancel(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +_asyncio_Task_cancel(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = {"msg", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *msg = Py_None; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - msg = args[0]; -skip_optional_pos: - return_value = _asyncio_Task_cancel_impl(self, msg); - -exit: - return return_value; + PyObject *return_value = NULL; + static const char * const _keywords[] = {"msg", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *msg = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + msg = args[0]; +skip_optional_pos: + return_value = _asyncio_Task_cancel_impl(self, msg); + +exit: + return return_value; } PyDoc_STRVAR(_asyncio_Task_get_stack__doc__, @@ -472,7 +472,7 @@ PyDoc_STRVAR(_asyncio_Task_get_stack__doc__, "returned for a suspended coroutine."); #define _ASYNCIO_TASK_GET_STACK_METHODDEF \ - {"get_stack", (PyCFunction)(void(*)(void))_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__}, + {"get_stack", (PyCFunction)(void(*)(void))_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__}, static PyObject * _asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit); @@ -482,20 +482,20 @@ _asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"limit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get_stack", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "get_stack", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *limit = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - limit = args[0]; -skip_optional_kwonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + limit = args[0]; +skip_optional_kwonly: return_value = _asyncio_Task_get_stack_impl(self, limit); exit: @@ -515,7 +515,7 @@ PyDoc_STRVAR(_asyncio_Task_print_stack__doc__, "to sys.stderr."); #define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \ - {"print_stack", (PyCFunction)(void(*)(void))_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__}, + {"print_stack", (PyCFunction)(void(*)(void))_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__}, static PyObject * _asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit, @@ -526,27 +526,27 @@ _asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"limit", "file", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "print_stack", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "print_stack", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *limit = Py_None; PyObject *file = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[0]) { - limit = args[0]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - file = args[1]; -skip_optional_kwonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + limit = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + file = args[1]; +skip_optional_kwonly: return_value = _asyncio_Task_print_stack_impl(self, limit, file); exit: @@ -569,48 +569,48 @@ PyDoc_STRVAR(_asyncio_Task_set_exception__doc__, #define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \ {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__}, -PyDoc_STRVAR(_asyncio_Task_get_coro__doc__, -"get_coro($self, /)\n" -"--\n" -"\n"); - -#define _ASYNCIO_TASK_GET_CORO_METHODDEF \ - {"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__}, - -static PyObject * -_asyncio_Task_get_coro_impl(TaskObj *self); - -static PyObject * -_asyncio_Task_get_coro(TaskObj *self, PyObject *Py_UNUSED(ignored)) -{ - return _asyncio_Task_get_coro_impl(self); -} - -PyDoc_STRVAR(_asyncio_Task_get_name__doc__, -"get_name($self, /)\n" -"--\n" -"\n"); - -#define _ASYNCIO_TASK_GET_NAME_METHODDEF \ - {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__}, - -static PyObject * -_asyncio_Task_get_name_impl(TaskObj *self); - -static PyObject * -_asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored)) -{ - return _asyncio_Task_get_name_impl(self); -} - -PyDoc_STRVAR(_asyncio_Task_set_name__doc__, -"set_name($self, value, /)\n" -"--\n" -"\n"); - -#define _ASYNCIO_TASK_SET_NAME_METHODDEF \ - {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__}, - +PyDoc_STRVAR(_asyncio_Task_get_coro__doc__, +"get_coro($self, /)\n" +"--\n" +"\n"); + +#define _ASYNCIO_TASK_GET_CORO_METHODDEF \ + {"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__}, + +static PyObject * +_asyncio_Task_get_coro_impl(TaskObj *self); + +static PyObject * +_asyncio_Task_get_coro(TaskObj *self, PyObject *Py_UNUSED(ignored)) +{ + return _asyncio_Task_get_coro_impl(self); +} + +PyDoc_STRVAR(_asyncio_Task_get_name__doc__, +"get_name($self, /)\n" +"--\n" +"\n"); + +#define _ASYNCIO_TASK_GET_NAME_METHODDEF \ + {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__}, + +static PyObject * +_asyncio_Task_get_name_impl(TaskObj *self); + +static PyObject * +_asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored)) +{ + return _asyncio_Task_get_name_impl(self); +} + +PyDoc_STRVAR(_asyncio_Task_set_name__doc__, +"set_name($self, value, /)\n" +"--\n" +"\n"); + +#define _ASYNCIO_TASK_SET_NAME_METHODDEF \ + {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__}, + PyDoc_STRVAR(_asyncio__get_running_loop__doc__, "_get_running_loop($module, /)\n" "--\n" @@ -698,7 +698,7 @@ PyDoc_STRVAR(_asyncio__register_task__doc__, "Returns None."); #define _ASYNCIO__REGISTER_TASK_METHODDEF \ - {"_register_task", (PyCFunction)(void(*)(void))_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__}, + {"_register_task", (PyCFunction)(void(*)(void))_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__}, static PyObject * _asyncio__register_task_impl(PyObject *module, PyObject *task); @@ -708,15 +708,15 @@ _asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"task", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_register_task", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "_register_task", 0}; + PyObject *argsbuf[1]; PyObject *task; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - task = args[0]; + task = args[0]; return_value = _asyncio__register_task_impl(module, task); exit: @@ -732,7 +732,7 @@ PyDoc_STRVAR(_asyncio__unregister_task__doc__, "Returns None."); #define _ASYNCIO__UNREGISTER_TASK_METHODDEF \ - {"_unregister_task", (PyCFunction)(void(*)(void))_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__}, + {"_unregister_task", (PyCFunction)(void(*)(void))_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__}, static PyObject * _asyncio__unregister_task_impl(PyObject *module, PyObject *task); @@ -742,15 +742,15 @@ _asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"task", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_unregister_task", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "_unregister_task", 0}; + PyObject *argsbuf[1]; PyObject *task; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - task = args[0]; + task = args[0]; return_value = _asyncio__unregister_task_impl(module, task); exit: @@ -768,7 +768,7 @@ PyDoc_STRVAR(_asyncio__enter_task__doc__, "Returns None."); #define _ASYNCIO__ENTER_TASK_METHODDEF \ - {"_enter_task", (PyCFunction)(void(*)(void))_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__}, + {"_enter_task", (PyCFunction)(void(*)(void))_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__}, static PyObject * _asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task); @@ -778,17 +778,17 @@ _asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", "task", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_enter_task", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "_enter_task", 0}; + PyObject *argsbuf[2]; PyObject *loop; PyObject *task; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } - loop = args[0]; - task = args[1]; + loop = args[0]; + task = args[1]; return_value = _asyncio__enter_task_impl(module, loop, task); exit: @@ -806,7 +806,7 @@ PyDoc_STRVAR(_asyncio__leave_task__doc__, "Returns None."); #define _ASYNCIO__LEAVE_TASK_METHODDEF \ - {"_leave_task", (PyCFunction)(void(*)(void))_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__}, + {"_leave_task", (PyCFunction)(void(*)(void))_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__}, static PyObject * _asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task); @@ -816,20 +816,20 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", "task", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_leave_task", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "_leave_task", 0}; + PyObject *argsbuf[2]; PyObject *loop; PyObject *task; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } - loop = args[0]; - task = args[1]; + loop = args[0]; + task = args[1]; return_value = _asyncio__leave_task_impl(module, loop, task); exit: return return_value; } -/*[clinic end generated code: output=d0fc522bcbff9d61 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d0fc522bcbff9d61 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_bisectmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_bisectmodule.c.h index 80ab7048f1..424b1517c5 100644 --- a/contrib/tools/python3/src/Modules/clinic/_bisectmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_bisectmodule.c.h @@ -1,306 +1,306 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_bisect_bisect_right__doc__, -"bisect_right($module, /, a, x, lo=0, hi=None)\n" -"--\n" -"\n" -"Return the index where to insert item x in list a, assuming a is sorted.\n" -"\n" -"The return value i is such that all e in a[:i] have e <= x, and all e in\n" -"a[i:] have e > x. So if x already appears in the list, i points just\n" -"beyond the rightmost x already there\n" -"\n" -"Optional args lo (default 0) and hi (default len(a)) bound the\n" -"slice of a to be searched."); - -#define _BISECT_BISECT_RIGHT_METHODDEF \ - {"bisect_right", (PyCFunction)(void(*)(void))_bisect_bisect_right, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_right__doc__}, - -static Py_ssize_t -_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi); - -static PyObject * -_bisect_bisect_right(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "bisect_right", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; - PyObject *a; - PyObject *x; - Py_ssize_t lo = 0; - Py_ssize_t hi = -1; - Py_ssize_t _return_value; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); - if (!args) { - goto exit; - } - a = args[0]; - x = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - lo = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { - goto exit; - } -skip_optional_pos: - _return_value = _bisect_bisect_right_impl(module, a, x, lo, hi); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromSsize_t(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_bisect_insort_right__doc__, -"insort_right($module, /, a, x, lo=0, hi=None)\n" -"--\n" -"\n" -"Insert item x in list a, and keep it sorted assuming a is sorted.\n" -"\n" -"If x is already in a, insert it to the right of the rightmost x.\n" -"\n" -"Optional args lo (default 0) and hi (default len(a)) bound the\n" -"slice of a to be searched."); - -#define _BISECT_INSORT_RIGHT_METHODDEF \ - {"insort_right", (PyCFunction)(void(*)(void))_bisect_insort_right, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_right__doc__}, - -static PyObject * -_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi); - -static PyObject * -_bisect_insort_right(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "insort_right", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; - PyObject *a; - PyObject *x; - Py_ssize_t lo = 0; - Py_ssize_t hi = -1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); - if (!args) { - goto exit; - } - a = args[0]; - x = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - lo = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { - goto exit; - } -skip_optional_pos: - return_value = _bisect_insort_right_impl(module, a, x, lo, hi); - -exit: - return return_value; -} - -PyDoc_STRVAR(_bisect_bisect_left__doc__, -"bisect_left($module, /, a, x, lo=0, hi=None)\n" -"--\n" -"\n" -"Return the index where to insert item x in list a, assuming a is sorted.\n" -"\n" -"The return value i is such that all e in a[:i] have e < x, and all e in\n" -"a[i:] have e >= x. So if x already appears in the list, i points just\n" -"before the leftmost x already there.\n" -"\n" -"Optional args lo (default 0) and hi (default len(a)) bound the\n" -"slice of a to be searched."); - -#define _BISECT_BISECT_LEFT_METHODDEF \ - {"bisect_left", (PyCFunction)(void(*)(void))_bisect_bisect_left, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_left__doc__}, - -static Py_ssize_t -_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi); - -static PyObject * -_bisect_bisect_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "bisect_left", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; - PyObject *a; - PyObject *x; - Py_ssize_t lo = 0; - Py_ssize_t hi = -1; - Py_ssize_t _return_value; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); - if (!args) { - goto exit; - } - a = args[0]; - x = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - lo = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { - goto exit; - } -skip_optional_pos: - _return_value = _bisect_bisect_left_impl(module, a, x, lo, hi); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromSsize_t(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_bisect_insort_left__doc__, -"insort_left($module, /, a, x, lo=0, hi=None)\n" -"--\n" -"\n" -"Insert item x in list a, and keep it sorted assuming a is sorted.\n" -"\n" -"If x is already in a, insert it to the left of the leftmost x.\n" -"\n" -"Optional args lo (default 0) and hi (default len(a)) bound the\n" -"slice of a to be searched."); - -#define _BISECT_INSORT_LEFT_METHODDEF \ - {"insort_left", (PyCFunction)(void(*)(void))_bisect_insort_left, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_left__doc__}, - -static PyObject * -_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi); - -static PyObject * -_bisect_insort_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "insort_left", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; - PyObject *a; - PyObject *x; - Py_ssize_t lo = 0; - Py_ssize_t hi = -1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); - if (!args) { - goto exit; - } - a = args[0]; - x = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - lo = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { - goto exit; - } -skip_optional_pos: - return_value = _bisect_insort_left_impl(module, a, x, lo, hi); - -exit: - return return_value; -} -/*[clinic end generated code: output=bcbd6c77331a08f0 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_bisect_bisect_right__doc__, +"bisect_right($module, /, a, x, lo=0, hi=None)\n" +"--\n" +"\n" +"Return the index where to insert item x in list a, assuming a is sorted.\n" +"\n" +"The return value i is such that all e in a[:i] have e <= x, and all e in\n" +"a[i:] have e > x. So if x already appears in the list, i points just\n" +"beyond the rightmost x already there\n" +"\n" +"Optional args lo (default 0) and hi (default len(a)) bound the\n" +"slice of a to be searched."); + +#define _BISECT_BISECT_RIGHT_METHODDEF \ + {"bisect_right", (PyCFunction)(void(*)(void))_bisect_bisect_right, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_right__doc__}, + +static Py_ssize_t +_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi); + +static PyObject * +_bisect_bisect_right(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "bisect_right", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *x; + Py_ssize_t lo = 0; + Py_ssize_t hi = -1; + Py_ssize_t _return_value; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + x = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + lo = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { + goto exit; + } +skip_optional_pos: + _return_value = _bisect_bisect_right_impl(module, a, x, lo, hi); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromSsize_t(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_bisect_insort_right__doc__, +"insort_right($module, /, a, x, lo=0, hi=None)\n" +"--\n" +"\n" +"Insert item x in list a, and keep it sorted assuming a is sorted.\n" +"\n" +"If x is already in a, insert it to the right of the rightmost x.\n" +"\n" +"Optional args lo (default 0) and hi (default len(a)) bound the\n" +"slice of a to be searched."); + +#define _BISECT_INSORT_RIGHT_METHODDEF \ + {"insort_right", (PyCFunction)(void(*)(void))_bisect_insort_right, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_right__doc__}, + +static PyObject * +_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi); + +static PyObject * +_bisect_insort_right(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "insort_right", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *x; + Py_ssize_t lo = 0; + Py_ssize_t hi = -1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + x = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + lo = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { + goto exit; + } +skip_optional_pos: + return_value = _bisect_insort_right_impl(module, a, x, lo, hi); + +exit: + return return_value; +} + +PyDoc_STRVAR(_bisect_bisect_left__doc__, +"bisect_left($module, /, a, x, lo=0, hi=None)\n" +"--\n" +"\n" +"Return the index where to insert item x in list a, assuming a is sorted.\n" +"\n" +"The return value i is such that all e in a[:i] have e < x, and all e in\n" +"a[i:] have e >= x. So if x already appears in the list, i points just\n" +"before the leftmost x already there.\n" +"\n" +"Optional args lo (default 0) and hi (default len(a)) bound the\n" +"slice of a to be searched."); + +#define _BISECT_BISECT_LEFT_METHODDEF \ + {"bisect_left", (PyCFunction)(void(*)(void))_bisect_bisect_left, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_left__doc__}, + +static Py_ssize_t +_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi); + +static PyObject * +_bisect_bisect_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "bisect_left", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *x; + Py_ssize_t lo = 0; + Py_ssize_t hi = -1; + Py_ssize_t _return_value; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + x = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + lo = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { + goto exit; + } +skip_optional_pos: + _return_value = _bisect_bisect_left_impl(module, a, x, lo, hi); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromSsize_t(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_bisect_insort_left__doc__, +"insort_left($module, /, a, x, lo=0, hi=None)\n" +"--\n" +"\n" +"Insert item x in list a, and keep it sorted assuming a is sorted.\n" +"\n" +"If x is already in a, insert it to the left of the leftmost x.\n" +"\n" +"Optional args lo (default 0) and hi (default len(a)) bound the\n" +"slice of a to be searched."); + +#define _BISECT_INSORT_LEFT_METHODDEF \ + {"insort_left", (PyCFunction)(void(*)(void))_bisect_insort_left, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_left__doc__}, + +static PyObject * +_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi); + +static PyObject * +_bisect_insort_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "x", "lo", "hi", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "insort_left", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *x; + Py_ssize_t lo = 0; + Py_ssize_t hi = -1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + x = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + lo = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!_Py_convert_optional_to_ssize_t(args[3], &hi)) { + goto exit; + } +skip_optional_pos: + return_value = _bisect_insort_left_impl(module, a, x, lo, hi); + +exit: + return return_value; +} +/*[clinic end generated code: output=bcbd6c77331a08f0 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_bz2module.c.h b/contrib/tools/python3/src/Modules/clinic/_bz2module.c.h index 0eb6280d6e..003f774d53 100644 --- a/contrib/tools/python3/src/Modules/clinic/_bz2module.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_bz2module.c.h @@ -25,13 +25,13 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _bz2_BZ2Compressor_compress_impl(self, &data); exit: @@ -85,26 +85,26 @@ _bz2_BZ2Compressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) int return_value = -1; int compresslevel = 9; - if (Py_IS_TYPE(self, &BZ2Compressor_Type) && + if (Py_IS_TYPE(self, &BZ2Compressor_Type) && !_PyArg_NoKeywords("BZ2Compressor", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("BZ2Compressor", PyTuple_GET_SIZE(args), 0, 1)) { - goto exit; - } - if (PyTuple_GET_SIZE(args) < 1) { - goto skip_optional; - } - if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - compresslevel = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); - if (compresslevel == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("BZ2Compressor", PyTuple_GET_SIZE(args), 0, 1)) { goto exit; } -skip_optional: + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + compresslevel = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); + if (compresslevel == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel); exit: @@ -131,7 +131,7 @@ PyDoc_STRVAR(_bz2_BZ2Decompressor_decompress__doc__, "the unused_data attribute."); #define _BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))_bz2_BZ2Decompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _bz2_BZ2Decompressor_decompress__doc__}, + {"decompress", (PyCFunction)(void(*)(void))_bz2_BZ2Decompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _bz2_BZ2Decompressor_decompress__doc__}, static PyObject * _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data, @@ -142,44 +142,44 @@ _bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "max_length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - max_length = ival; - } -skip_optional_pos: + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + max_length = ival; + } +skip_optional_pos: return_value = _bz2_BZ2Decompressor_decompress_impl(self, &data, max_length); exit: @@ -207,11 +207,11 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - if (Py_IS_TYPE(self, &BZ2Decompressor_Type) && + if (Py_IS_TYPE(self, &BZ2Decompressor_Type) && !_PyArg_NoPositional("BZ2Decompressor", args)) { goto exit; } - if (Py_IS_TYPE(self, &BZ2Decompressor_Type) && + if (Py_IS_TYPE(self, &BZ2Decompressor_Type) && !_PyArg_NoKeywords("BZ2Decompressor", kwargs)) { goto exit; } @@ -220,4 +220,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3f3f1e788fe28ee1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3f3f1e788fe28ee1 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_codecsmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_codecsmodule.c.h index 7ddc36de8a..ad8e11127f 100644 --- a/contrib/tools/python3/src/Modules/clinic/_codecsmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_codecsmodule.c.h @@ -33,19 +33,19 @@ _codecs_lookup(PyObject *module, PyObject *arg) PyObject *return_value = NULL; const char *encoding; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("lookup", "argument", "str", arg); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("lookup", "argument", "str", arg); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _codecs_lookup_impl(module, encoding); exit: @@ -65,7 +65,7 @@ PyDoc_STRVAR(_codecs_encode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))_codecs_encode, METH_FASTCALL|METH_KEYWORDS, _codecs_encode__doc__}, + {"encode", (PyCFunction)(void(*)(void))_codecs_encode, METH_FASTCALL|METH_KEYWORDS, _codecs_encode__doc__}, static PyObject * _codecs_encode_impl(PyObject *module, PyObject *obj, const char *encoding, @@ -76,53 +76,53 @@ _codecs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; const char *encoding = NULL; const char *errors = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - obj = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[1]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("encode", "argument 'errors'", "str", args[2]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[1]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("encode", "argument 'errors'", "str", args[2]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = _codecs_encode_impl(module, obj, encoding, errors); exit: @@ -142,7 +142,7 @@ PyDoc_STRVAR(_codecs_decode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_codecs_decode, METH_FASTCALL|METH_KEYWORDS, _codecs_decode__doc__}, + {"decode", (PyCFunction)(void(*)(void))_codecs_decode, METH_FASTCALL|METH_KEYWORDS, _codecs_decode__doc__}, static PyObject * _codecs_decode_impl(PyObject *module, PyObject *obj, const char *encoding, @@ -153,53 +153,53 @@ _codecs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; const char *encoding = NULL; const char *errors = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - obj = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[1]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("decode", "argument 'errors'", "str", args[2]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[1]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("decode", "argument 'errors'", "str", args[2]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = _codecs_decode_impl(module, obj, encoding, errors); exit: @@ -224,19 +224,19 @@ _codecs__forget_codec(PyObject *module, PyObject *arg) PyObject *return_value = NULL; const char *encoding; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("_forget_codec", "argument", "str", arg); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("_forget_codec", "argument", "str", arg); goto exit; } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _codecs__forget_codec_impl(module, encoding); exit: @@ -249,7 +249,7 @@ PyDoc_STRVAR(_codecs_escape_decode__doc__, "\n"); #define _CODECS_ESCAPE_DECODE_METHODDEF \ - {"escape_decode", (PyCFunction)(void(*)(void))_codecs_escape_decode, METH_FASTCALL, _codecs_escape_decode__doc__}, + {"escape_decode", (PyCFunction)(void(*)(void))_codecs_escape_decode, METH_FASTCALL, _codecs_escape_decode__doc__}, static PyObject * _codecs_escape_decode_impl(PyObject *module, Py_buffer *data, @@ -262,48 +262,48 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!_PyArg_CheckPositional("escape_decode", nargs, 1, 2)) { - goto exit; - } - if (PyUnicode_Check(args[0])) { - Py_ssize_t len; - const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); - if (ptr == NULL) { - goto exit; - } - PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); - } - else { /* any bytes-like object */ - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("escape_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("escape_decode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("escape_decode", nargs, 1, 2)) { + goto exit; + } + if (PyUnicode_Check(args[0])) { + Py_ssize_t len; + const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); + if (ptr == NULL) { + goto exit; + } + PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); + } + else { /* any bytes-like object */ + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("escape_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("escape_decode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_escape_decode_impl(module, &data, errors); exit: @@ -321,7 +321,7 @@ PyDoc_STRVAR(_codecs_escape_encode__doc__, "\n"); #define _CODECS_ESCAPE_ENCODE_METHODDEF \ - {"escape_encode", (PyCFunction)(void(*)(void))_codecs_escape_encode, METH_FASTCALL, _codecs_escape_encode__doc__}, + {"escape_encode", (PyCFunction)(void(*)(void))_codecs_escape_encode, METH_FASTCALL, _codecs_escape_encode__doc__}, static PyObject * _codecs_escape_encode_impl(PyObject *module, PyObject *data, @@ -334,37 +334,37 @@ _codecs_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *data; const char *errors = NULL; - if (!_PyArg_CheckPositional("escape_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyBytes_Check(args[0])) { - _PyArg_BadArgument("escape_encode", "argument 1", "bytes", args[0]); - goto exit; - } - data = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("escape_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: - return_value = _codecs_escape_encode_impl(module, data, errors); + if (!_PyArg_CheckPositional("escape_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyBytes_Check(args[0])) { + _PyArg_BadArgument("escape_encode", "argument 1", "bytes", args[0]); + goto exit; + } + data = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("escape_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: + return_value = _codecs_escape_encode_impl(module, data, errors); exit: return return_value; @@ -376,7 +376,7 @@ PyDoc_STRVAR(_codecs_utf_7_decode__doc__, "\n"); #define _CODECS_UTF_7_DECODE_METHODDEF \ - {"utf_7_decode", (PyCFunction)(void(*)(void))_codecs_utf_7_decode, METH_FASTCALL, _codecs_utf_7_decode__doc__}, + {"utf_7_decode", (PyCFunction)(void(*)(void))_codecs_utf_7_decode, METH_FASTCALL, _codecs_utf_7_decode__doc__}, static PyObject * _codecs_utf_7_decode_impl(PyObject *module, Py_buffer *data, @@ -390,50 +390,50 @@ _codecs_utf_7_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_7_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_7_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_7_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_7_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_7_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_7_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_7_decode_impl(module, &data, errors, final); exit: @@ -451,7 +451,7 @@ PyDoc_STRVAR(_codecs_utf_8_decode__doc__, "\n"); #define _CODECS_UTF_8_DECODE_METHODDEF \ - {"utf_8_decode", (PyCFunction)(void(*)(void))_codecs_utf_8_decode, METH_FASTCALL, _codecs_utf_8_decode__doc__}, + {"utf_8_decode", (PyCFunction)(void(*)(void))_codecs_utf_8_decode, METH_FASTCALL, _codecs_utf_8_decode__doc__}, static PyObject * _codecs_utf_8_decode_impl(PyObject *module, Py_buffer *data, @@ -465,50 +465,50 @@ _codecs_utf_8_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_8_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_8_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_8_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_8_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_8_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_8_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_8_decode_impl(module, &data, errors, final); exit: @@ -526,7 +526,7 @@ PyDoc_STRVAR(_codecs_utf_16_decode__doc__, "\n"); #define _CODECS_UTF_16_DECODE_METHODDEF \ - {"utf_16_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_decode, METH_FASTCALL, _codecs_utf_16_decode__doc__}, + {"utf_16_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_decode, METH_FASTCALL, _codecs_utf_16_decode__doc__}, static PyObject * _codecs_utf_16_decode_impl(PyObject *module, Py_buffer *data, @@ -540,50 +540,50 @@ _codecs_utf_16_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_16_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_16_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_16_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_16_decode_impl(module, &data, errors, final); exit: @@ -601,7 +601,7 @@ PyDoc_STRVAR(_codecs_utf_16_le_decode__doc__, "\n"); #define _CODECS_UTF_16_LE_DECODE_METHODDEF \ - {"utf_16_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_decode, METH_FASTCALL, _codecs_utf_16_le_decode__doc__}, + {"utf_16_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_decode, METH_FASTCALL, _codecs_utf_16_le_decode__doc__}, static PyObject * _codecs_utf_16_le_decode_impl(PyObject *module, Py_buffer *data, @@ -615,50 +615,50 @@ _codecs_utf_16_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_16_le_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_16_le_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_le_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_le_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_16_le_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_le_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final); exit: @@ -676,7 +676,7 @@ PyDoc_STRVAR(_codecs_utf_16_be_decode__doc__, "\n"); #define _CODECS_UTF_16_BE_DECODE_METHODDEF \ - {"utf_16_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_decode, METH_FASTCALL, _codecs_utf_16_be_decode__doc__}, + {"utf_16_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_decode, METH_FASTCALL, _codecs_utf_16_be_decode__doc__}, static PyObject * _codecs_utf_16_be_decode_impl(PyObject *module, Py_buffer *data, @@ -690,50 +690,50 @@ _codecs_utf_16_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_16_be_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_16_be_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_be_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_be_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_16_be_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_be_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final); exit: @@ -752,7 +752,7 @@ PyDoc_STRVAR(_codecs_utf_16_ex_decode__doc__, "\n"); #define _CODECS_UTF_16_EX_DECODE_METHODDEF \ - {"utf_16_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_ex_decode, METH_FASTCALL, _codecs_utf_16_ex_decode__doc__}, + {"utf_16_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_ex_decode, METH_FASTCALL, _codecs_utf_16_ex_decode__doc__}, static PyObject * _codecs_utf_16_ex_decode_impl(PyObject *module, Py_buffer *data, @@ -767,62 +767,62 @@ _codecs_utf_16_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar int byteorder = 0; int final = 0; - if (!_PyArg_CheckPositional("utf_16_ex_decode", nargs, 1, 4)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_16_ex_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_ex_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - byteorder = _PyLong_AsInt(args[2]); - if (byteorder == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[3]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_ex_decode", nargs, 1, 4)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_16_ex_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_ex_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + byteorder = _PyLong_AsInt(args[2]); + if (byteorder == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[3]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final); exit: @@ -840,7 +840,7 @@ PyDoc_STRVAR(_codecs_utf_32_decode__doc__, "\n"); #define _CODECS_UTF_32_DECODE_METHODDEF \ - {"utf_32_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_decode, METH_FASTCALL, _codecs_utf_32_decode__doc__}, + {"utf_32_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_decode, METH_FASTCALL, _codecs_utf_32_decode__doc__}, static PyObject * _codecs_utf_32_decode_impl(PyObject *module, Py_buffer *data, @@ -854,50 +854,50 @@ _codecs_utf_32_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_32_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_32_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_32_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_32_decode_impl(module, &data, errors, final); exit: @@ -915,7 +915,7 @@ PyDoc_STRVAR(_codecs_utf_32_le_decode__doc__, "\n"); #define _CODECS_UTF_32_LE_DECODE_METHODDEF \ - {"utf_32_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_decode, METH_FASTCALL, _codecs_utf_32_le_decode__doc__}, + {"utf_32_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_decode, METH_FASTCALL, _codecs_utf_32_le_decode__doc__}, static PyObject * _codecs_utf_32_le_decode_impl(PyObject *module, Py_buffer *data, @@ -929,50 +929,50 @@ _codecs_utf_32_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_32_le_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_32_le_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_le_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_le_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_32_le_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_le_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final); exit: @@ -990,7 +990,7 @@ PyDoc_STRVAR(_codecs_utf_32_be_decode__doc__, "\n"); #define _CODECS_UTF_32_BE_DECODE_METHODDEF \ - {"utf_32_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_decode, METH_FASTCALL, _codecs_utf_32_be_decode__doc__}, + {"utf_32_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_decode, METH_FASTCALL, _codecs_utf_32_be_decode__doc__}, static PyObject * _codecs_utf_32_be_decode_impl(PyObject *module, Py_buffer *data, @@ -1004,50 +1004,50 @@ _codecs_utf_32_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("utf_32_be_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_32_be_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_be_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_be_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_32_be_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_be_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final); exit: @@ -1066,7 +1066,7 @@ PyDoc_STRVAR(_codecs_utf_32_ex_decode__doc__, "\n"); #define _CODECS_UTF_32_EX_DECODE_METHODDEF \ - {"utf_32_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_ex_decode, METH_FASTCALL, _codecs_utf_32_ex_decode__doc__}, + {"utf_32_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_ex_decode, METH_FASTCALL, _codecs_utf_32_ex_decode__doc__}, static PyObject * _codecs_utf_32_ex_decode_impl(PyObject *module, Py_buffer *data, @@ -1081,62 +1081,62 @@ _codecs_utf_32_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar int byteorder = 0; int final = 0; - if (!_PyArg_CheckPositional("utf_32_ex_decode", nargs, 1, 4)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("utf_32_ex_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_ex_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - byteorder = _PyLong_AsInt(args[2]); - if (byteorder == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[3]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_ex_decode", nargs, 1, 4)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("utf_32_ex_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_ex_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + byteorder = _PyLong_AsInt(args[2]); + if (byteorder == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[3]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final); exit: @@ -1149,16 +1149,16 @@ exit: } PyDoc_STRVAR(_codecs_unicode_escape_decode__doc__, -"unicode_escape_decode($module, data, errors=None, final=True, /)\n" +"unicode_escape_decode($module, data, errors=None, final=True, /)\n" "--\n" "\n"); #define _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_decode, METH_FASTCALL, _codecs_unicode_escape_decode__doc__}, + {"unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_decode, METH_FASTCALL, _codecs_unicode_escape_decode__doc__}, static PyObject * _codecs_unicode_escape_decode_impl(PyObject *module, Py_buffer *data, - const char *errors, int final); + const char *errors, int final); static PyObject * _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) @@ -1166,63 +1166,63 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_ PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - int final = 1; - - if (!_PyArg_CheckPositional("unicode_escape_decode", nargs, 1, 3)) { - goto exit; - } - if (PyUnicode_Check(args[0])) { - Py_ssize_t len; - const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); - if (ptr == NULL) { - goto exit; - } - PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); - } - else { /* any bytes-like object */ - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("unicode_escape_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("unicode_escape_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _codecs_unicode_escape_decode_impl(module, &data, errors, final); + int final = 1; + + if (!_PyArg_CheckPositional("unicode_escape_decode", nargs, 1, 3)) { + goto exit; + } + if (PyUnicode_Check(args[0])) { + Py_ssize_t len; + const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); + if (ptr == NULL) { + goto exit; + } + PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); + } + else { /* any bytes-like object */ + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("unicode_escape_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("unicode_escape_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _codecs_unicode_escape_decode_impl(module, &data, errors, final); exit: /* Cleanup for data */ @@ -1234,16 +1234,16 @@ exit: } PyDoc_STRVAR(_codecs_raw_unicode_escape_decode__doc__, -"raw_unicode_escape_decode($module, data, errors=None, final=True, /)\n" +"raw_unicode_escape_decode($module, data, errors=None, final=True, /)\n" "--\n" "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"raw_unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_decode, METH_FASTCALL, _codecs_raw_unicode_escape_decode__doc__}, + {"raw_unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_decode, METH_FASTCALL, _codecs_raw_unicode_escape_decode__doc__}, static PyObject * _codecs_raw_unicode_escape_decode_impl(PyObject *module, Py_buffer *data, - const char *errors, int final); + const char *errors, int final); static PyObject * _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) @@ -1251,63 +1251,63 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - int final = 1; - - if (!_PyArg_CheckPositional("raw_unicode_escape_decode", nargs, 1, 3)) { - goto exit; - } - if (PyUnicode_Check(args[0])) { - Py_ssize_t len; - const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); - if (ptr == NULL) { - goto exit; - } - PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); - } - else { /* any bytes-like object */ - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("raw_unicode_escape_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("raw_unicode_escape_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors, final); + int final = 1; + + if (!_PyArg_CheckPositional("raw_unicode_escape_decode", nargs, 1, 3)) { + goto exit; + } + if (PyUnicode_Check(args[0])) { + Py_ssize_t len; + const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); + if (ptr == NULL) { + goto exit; + } + PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); + } + else { /* any bytes-like object */ + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("raw_unicode_escape_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("raw_unicode_escape_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors, final); exit: /* Cleanup for data */ @@ -1324,7 +1324,7 @@ PyDoc_STRVAR(_codecs_latin_1_decode__doc__, "\n"); #define _CODECS_LATIN_1_DECODE_METHODDEF \ - {"latin_1_decode", (PyCFunction)(void(*)(void))_codecs_latin_1_decode, METH_FASTCALL, _codecs_latin_1_decode__doc__}, + {"latin_1_decode", (PyCFunction)(void(*)(void))_codecs_latin_1_decode, METH_FASTCALL, _codecs_latin_1_decode__doc__}, static PyObject * _codecs_latin_1_decode_impl(PyObject *module, Py_buffer *data, @@ -1337,38 +1337,38 @@ _codecs_latin_1_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!_PyArg_CheckPositional("latin_1_decode", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("latin_1_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("latin_1_decode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("latin_1_decode", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("latin_1_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("latin_1_decode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_latin_1_decode_impl(module, &data, errors); exit: @@ -1386,7 +1386,7 @@ PyDoc_STRVAR(_codecs_ascii_decode__doc__, "\n"); #define _CODECS_ASCII_DECODE_METHODDEF \ - {"ascii_decode", (PyCFunction)(void(*)(void))_codecs_ascii_decode, METH_FASTCALL, _codecs_ascii_decode__doc__}, + {"ascii_decode", (PyCFunction)(void(*)(void))_codecs_ascii_decode, METH_FASTCALL, _codecs_ascii_decode__doc__}, static PyObject * _codecs_ascii_decode_impl(PyObject *module, Py_buffer *data, @@ -1399,38 +1399,38 @@ _codecs_ascii_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!_PyArg_CheckPositional("ascii_decode", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("ascii_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("ascii_decode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("ascii_decode", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("ascii_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ascii_decode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_ascii_decode_impl(module, &data, errors); exit: @@ -1448,7 +1448,7 @@ PyDoc_STRVAR(_codecs_charmap_decode__doc__, "\n"); #define _CODECS_CHARMAP_DECODE_METHODDEF \ - {"charmap_decode", (PyCFunction)(void(*)(void))_codecs_charmap_decode, METH_FASTCALL, _codecs_charmap_decode__doc__}, + {"charmap_decode", (PyCFunction)(void(*)(void))_codecs_charmap_decode, METH_FASTCALL, _codecs_charmap_decode__doc__}, static PyObject * _codecs_charmap_decode_impl(PyObject *module, Py_buffer *data, @@ -1460,44 +1460,44 @@ _codecs_charmap_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - PyObject *mapping = Py_None; - - if (!_PyArg_CheckPositional("charmap_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("charmap_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("charmap_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - mapping = args[2]; -skip_optional: + PyObject *mapping = Py_None; + + if (!_PyArg_CheckPositional("charmap_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("charmap_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("charmap_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + mapping = args[2]; +skip_optional: return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping); exit: @@ -1517,7 +1517,7 @@ PyDoc_STRVAR(_codecs_mbcs_decode__doc__, "\n"); #define _CODECS_MBCS_DECODE_METHODDEF \ - {"mbcs_decode", (PyCFunction)(void(*)(void))_codecs_mbcs_decode, METH_FASTCALL, _codecs_mbcs_decode__doc__}, + {"mbcs_decode", (PyCFunction)(void(*)(void))_codecs_mbcs_decode, METH_FASTCALL, _codecs_mbcs_decode__doc__}, static PyObject * _codecs_mbcs_decode_impl(PyObject *module, Py_buffer *data, @@ -1531,50 +1531,50 @@ _codecs_mbcs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("mbcs_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("mbcs_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("mbcs_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("mbcs_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("mbcs_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("mbcs_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_mbcs_decode_impl(module, &data, errors, final); exit: @@ -1596,7 +1596,7 @@ PyDoc_STRVAR(_codecs_oem_decode__doc__, "\n"); #define _CODECS_OEM_DECODE_METHODDEF \ - {"oem_decode", (PyCFunction)(void(*)(void))_codecs_oem_decode, METH_FASTCALL, _codecs_oem_decode__doc__}, + {"oem_decode", (PyCFunction)(void(*)(void))_codecs_oem_decode, METH_FASTCALL, _codecs_oem_decode__doc__}, static PyObject * _codecs_oem_decode_impl(PyObject *module, Py_buffer *data, @@ -1610,50 +1610,50 @@ _codecs_oem_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("oem_decode", nargs, 1, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("oem_decode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("oem_decode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[2]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("oem_decode", nargs, 1, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("oem_decode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("oem_decode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[2]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_oem_decode_impl(module, &data, errors, final); exit: @@ -1675,7 +1675,7 @@ PyDoc_STRVAR(_codecs_code_page_decode__doc__, "\n"); #define _CODECS_CODE_PAGE_DECODE_METHODDEF \ - {"code_page_decode", (PyCFunction)(void(*)(void))_codecs_code_page_decode, METH_FASTCALL, _codecs_code_page_decode__doc__}, + {"code_page_decode", (PyCFunction)(void(*)(void))_codecs_code_page_decode, METH_FASTCALL, _codecs_code_page_decode__doc__}, static PyObject * _codecs_code_page_decode_impl(PyObject *module, int codepage, @@ -1690,59 +1690,59 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar const char *errors = NULL; int final = 0; - if (!_PyArg_CheckPositional("code_page_decode", nargs, 2, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - codepage = _PyLong_AsInt(args[0]); - if (codepage == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("code_page_decode", "argument 2", "contiguous buffer", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (args[2] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("code_page_decode", "argument 3", "str or None", args[2]); - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[3]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("code_page_decode", nargs, 2, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + codepage = _PyLong_AsInt(args[0]); + if (codepage == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("code_page_decode", "argument 2", "contiguous buffer", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (args[2] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[2])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("code_page_decode", "argument 3", "str or None", args[2]); + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[3]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final); exit: @@ -1762,7 +1762,7 @@ PyDoc_STRVAR(_codecs_readbuffer_encode__doc__, "\n"); #define _CODECS_READBUFFER_ENCODE_METHODDEF \ - {"readbuffer_encode", (PyCFunction)(void(*)(void))_codecs_readbuffer_encode, METH_FASTCALL, _codecs_readbuffer_encode__doc__}, + {"readbuffer_encode", (PyCFunction)(void(*)(void))_codecs_readbuffer_encode, METH_FASTCALL, _codecs_readbuffer_encode__doc__}, static PyObject * _codecs_readbuffer_encode_impl(PyObject *module, Py_buffer *data, @@ -1775,48 +1775,48 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!_PyArg_CheckPositional("readbuffer_encode", nargs, 1, 2)) { - goto exit; - } - if (PyUnicode_Check(args[0])) { - Py_ssize_t len; - const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); - if (ptr == NULL) { - goto exit; - } - PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); - } - else { /* any bytes-like object */ - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("readbuffer_encode", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - } - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("readbuffer_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("readbuffer_encode", nargs, 1, 2)) { + goto exit; + } + if (PyUnicode_Check(args[0])) { + Py_ssize_t len; + const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); + if (ptr == NULL) { + goto exit; + } + PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0); + } + else { /* any bytes-like object */ + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("readbuffer_encode", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + } + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("readbuffer_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_readbuffer_encode_impl(module, &data, errors); exit: @@ -1834,7 +1834,7 @@ PyDoc_STRVAR(_codecs_utf_7_encode__doc__, "\n"); #define _CODECS_UTF_7_ENCODE_METHODDEF \ - {"utf_7_encode", (PyCFunction)(void(*)(void))_codecs_utf_7_encode, METH_FASTCALL, _codecs_utf_7_encode__doc__}, + {"utf_7_encode", (PyCFunction)(void(*)(void))_codecs_utf_7_encode, METH_FASTCALL, _codecs_utf_7_encode__doc__}, static PyObject * _codecs_utf_7_encode_impl(PyObject *module, PyObject *str, @@ -1847,39 +1847,39 @@ _codecs_utf_7_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_7_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_7_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_7_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_7_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_7_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_7_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_7_encode_impl(module, str, errors); exit: @@ -1892,7 +1892,7 @@ PyDoc_STRVAR(_codecs_utf_8_encode__doc__, "\n"); #define _CODECS_UTF_8_ENCODE_METHODDEF \ - {"utf_8_encode", (PyCFunction)(void(*)(void))_codecs_utf_8_encode, METH_FASTCALL, _codecs_utf_8_encode__doc__}, + {"utf_8_encode", (PyCFunction)(void(*)(void))_codecs_utf_8_encode, METH_FASTCALL, _codecs_utf_8_encode__doc__}, static PyObject * _codecs_utf_8_encode_impl(PyObject *module, PyObject *str, @@ -1905,39 +1905,39 @@ _codecs_utf_8_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_8_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_8_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_8_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_8_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_8_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_8_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_8_encode_impl(module, str, errors); exit: @@ -1950,7 +1950,7 @@ PyDoc_STRVAR(_codecs_utf_16_encode__doc__, "\n"); #define _CODECS_UTF_16_ENCODE_METHODDEF \ - {"utf_16_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_encode, METH_FASTCALL, _codecs_utf_16_encode__doc__}, + {"utf_16_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_encode, METH_FASTCALL, _codecs_utf_16_encode__doc__}, static PyObject * _codecs_utf_16_encode_impl(PyObject *module, PyObject *str, @@ -1964,51 +1964,51 @@ _codecs_utf_16_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int byteorder = 0; - if (!_PyArg_CheckPositional("utf_16_encode", nargs, 1, 3)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_16_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_encode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - byteorder = _PyLong_AsInt(args[2]); - if (byteorder == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_encode", nargs, 1, 3)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_16_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_encode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + byteorder = _PyLong_AsInt(args[2]); + if (byteorder == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder); exit: @@ -2021,7 +2021,7 @@ PyDoc_STRVAR(_codecs_utf_16_le_encode__doc__, "\n"); #define _CODECS_UTF_16_LE_ENCODE_METHODDEF \ - {"utf_16_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_encode, METH_FASTCALL, _codecs_utf_16_le_encode__doc__}, + {"utf_16_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_encode, METH_FASTCALL, _codecs_utf_16_le_encode__doc__}, static PyObject * _codecs_utf_16_le_encode_impl(PyObject *module, PyObject *str, @@ -2034,39 +2034,39 @@ _codecs_utf_16_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_16_le_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_16_le_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_le_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_le_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_16_le_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_le_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_16_le_encode_impl(module, str, errors); exit: @@ -2079,7 +2079,7 @@ PyDoc_STRVAR(_codecs_utf_16_be_encode__doc__, "\n"); #define _CODECS_UTF_16_BE_ENCODE_METHODDEF \ - {"utf_16_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_encode, METH_FASTCALL, _codecs_utf_16_be_encode__doc__}, + {"utf_16_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_encode, METH_FASTCALL, _codecs_utf_16_be_encode__doc__}, static PyObject * _codecs_utf_16_be_encode_impl(PyObject *module, PyObject *str, @@ -2092,39 +2092,39 @@ _codecs_utf_16_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_16_be_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_16_be_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_16_be_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_16_be_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_16_be_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_16_be_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_16_be_encode_impl(module, str, errors); exit: @@ -2137,7 +2137,7 @@ PyDoc_STRVAR(_codecs_utf_32_encode__doc__, "\n"); #define _CODECS_UTF_32_ENCODE_METHODDEF \ - {"utf_32_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_encode, METH_FASTCALL, _codecs_utf_32_encode__doc__}, + {"utf_32_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_encode, METH_FASTCALL, _codecs_utf_32_encode__doc__}, static PyObject * _codecs_utf_32_encode_impl(PyObject *module, PyObject *str, @@ -2151,51 +2151,51 @@ _codecs_utf_32_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *errors = NULL; int byteorder = 0; - if (!_PyArg_CheckPositional("utf_32_encode", nargs, 1, 3)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_32_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_encode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - byteorder = _PyLong_AsInt(args[2]); - if (byteorder == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_encode", nargs, 1, 3)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_32_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_encode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + byteorder = _PyLong_AsInt(args[2]); + if (byteorder == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder); exit: @@ -2208,7 +2208,7 @@ PyDoc_STRVAR(_codecs_utf_32_le_encode__doc__, "\n"); #define _CODECS_UTF_32_LE_ENCODE_METHODDEF \ - {"utf_32_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_encode, METH_FASTCALL, _codecs_utf_32_le_encode__doc__}, + {"utf_32_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_encode, METH_FASTCALL, _codecs_utf_32_le_encode__doc__}, static PyObject * _codecs_utf_32_le_encode_impl(PyObject *module, PyObject *str, @@ -2221,39 +2221,39 @@ _codecs_utf_32_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_32_le_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_32_le_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_le_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_le_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_32_le_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_le_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_32_le_encode_impl(module, str, errors); exit: @@ -2266,7 +2266,7 @@ PyDoc_STRVAR(_codecs_utf_32_be_encode__doc__, "\n"); #define _CODECS_UTF_32_BE_ENCODE_METHODDEF \ - {"utf_32_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_encode, METH_FASTCALL, _codecs_utf_32_be_encode__doc__}, + {"utf_32_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_encode, METH_FASTCALL, _codecs_utf_32_be_encode__doc__}, static PyObject * _codecs_utf_32_be_encode_impl(PyObject *module, PyObject *str, @@ -2279,39 +2279,39 @@ _codecs_utf_32_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("utf_32_be_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("utf_32_be_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("utf_32_be_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("utf_32_be_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("utf_32_be_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("utf_32_be_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_utf_32_be_encode_impl(module, str, errors); exit: @@ -2324,7 +2324,7 @@ PyDoc_STRVAR(_codecs_unicode_escape_encode__doc__, "\n"); #define _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_encode, METH_FASTCALL, _codecs_unicode_escape_encode__doc__}, + {"unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_encode, METH_FASTCALL, _codecs_unicode_escape_encode__doc__}, static PyObject * _codecs_unicode_escape_encode_impl(PyObject *module, PyObject *str, @@ -2337,39 +2337,39 @@ _codecs_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_ PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("unicode_escape_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("unicode_escape_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("unicode_escape_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("unicode_escape_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("unicode_escape_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("unicode_escape_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_unicode_escape_encode_impl(module, str, errors); exit: @@ -2382,7 +2382,7 @@ PyDoc_STRVAR(_codecs_raw_unicode_escape_encode__doc__, "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"raw_unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_encode, METH_FASTCALL, _codecs_raw_unicode_escape_encode__doc__}, + {"raw_unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_encode, METH_FASTCALL, _codecs_raw_unicode_escape_encode__doc__}, static PyObject * _codecs_raw_unicode_escape_encode_impl(PyObject *module, PyObject *str, @@ -2395,39 +2395,39 @@ _codecs_raw_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ss PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("raw_unicode_escape_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("raw_unicode_escape_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("raw_unicode_escape_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("raw_unicode_escape_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("raw_unicode_escape_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("raw_unicode_escape_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors); exit: @@ -2440,7 +2440,7 @@ PyDoc_STRVAR(_codecs_latin_1_encode__doc__, "\n"); #define _CODECS_LATIN_1_ENCODE_METHODDEF \ - {"latin_1_encode", (PyCFunction)(void(*)(void))_codecs_latin_1_encode, METH_FASTCALL, _codecs_latin_1_encode__doc__}, + {"latin_1_encode", (PyCFunction)(void(*)(void))_codecs_latin_1_encode, METH_FASTCALL, _codecs_latin_1_encode__doc__}, static PyObject * _codecs_latin_1_encode_impl(PyObject *module, PyObject *str, @@ -2453,39 +2453,39 @@ _codecs_latin_1_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("latin_1_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("latin_1_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("latin_1_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("latin_1_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("latin_1_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("latin_1_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_latin_1_encode_impl(module, str, errors); exit: @@ -2498,7 +2498,7 @@ PyDoc_STRVAR(_codecs_ascii_encode__doc__, "\n"); #define _CODECS_ASCII_ENCODE_METHODDEF \ - {"ascii_encode", (PyCFunction)(void(*)(void))_codecs_ascii_encode, METH_FASTCALL, _codecs_ascii_encode__doc__}, + {"ascii_encode", (PyCFunction)(void(*)(void))_codecs_ascii_encode, METH_FASTCALL, _codecs_ascii_encode__doc__}, static PyObject * _codecs_ascii_encode_impl(PyObject *module, PyObject *str, @@ -2511,39 +2511,39 @@ _codecs_ascii_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("ascii_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("ascii_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("ascii_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("ascii_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("ascii_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ascii_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_ascii_encode_impl(module, str, errors); exit: @@ -2556,7 +2556,7 @@ PyDoc_STRVAR(_codecs_charmap_encode__doc__, "\n"); #define _CODECS_CHARMAP_ENCODE_METHODDEF \ - {"charmap_encode", (PyCFunction)(void(*)(void))_codecs_charmap_encode, METH_FASTCALL, _codecs_charmap_encode__doc__}, + {"charmap_encode", (PyCFunction)(void(*)(void))_codecs_charmap_encode, METH_FASTCALL, _codecs_charmap_encode__doc__}, static PyObject * _codecs_charmap_encode_impl(PyObject *module, PyObject *str, @@ -2568,45 +2568,45 @@ _codecs_charmap_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - PyObject *mapping = Py_None; - - if (!_PyArg_CheckPositional("charmap_encode", nargs, 1, 3)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("charmap_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("charmap_encode", "argument 2", "str or None", args[1]); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - mapping = args[2]; -skip_optional: + PyObject *mapping = Py_None; + + if (!_PyArg_CheckPositional("charmap_encode", nargs, 1, 3)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("charmap_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("charmap_encode", "argument 2", "str or None", args[1]); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + mapping = args[2]; +skip_optional: return_value = _codecs_charmap_encode_impl(module, str, errors, mapping); exit: @@ -2630,14 +2630,14 @@ _codecs_charmap_build(PyObject *module, PyObject *arg) PyObject *return_value = NULL; PyObject *map; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("charmap_build", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("charmap_build", "argument", "str", arg); goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - map = arg; + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + map = arg; return_value = _codecs_charmap_build_impl(module, map); exit: @@ -2652,7 +2652,7 @@ PyDoc_STRVAR(_codecs_mbcs_encode__doc__, "\n"); #define _CODECS_MBCS_ENCODE_METHODDEF \ - {"mbcs_encode", (PyCFunction)(void(*)(void))_codecs_mbcs_encode, METH_FASTCALL, _codecs_mbcs_encode__doc__}, + {"mbcs_encode", (PyCFunction)(void(*)(void))_codecs_mbcs_encode, METH_FASTCALL, _codecs_mbcs_encode__doc__}, static PyObject * _codecs_mbcs_encode_impl(PyObject *module, PyObject *str, const char *errors); @@ -2664,39 +2664,39 @@ _codecs_mbcs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("mbcs_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("mbcs_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("mbcs_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("mbcs_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("mbcs_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("mbcs_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_mbcs_encode_impl(module, str, errors); exit: @@ -2713,7 +2713,7 @@ PyDoc_STRVAR(_codecs_oem_encode__doc__, "\n"); #define _CODECS_OEM_ENCODE_METHODDEF \ - {"oem_encode", (PyCFunction)(void(*)(void))_codecs_oem_encode, METH_FASTCALL, _codecs_oem_encode__doc__}, + {"oem_encode", (PyCFunction)(void(*)(void))_codecs_oem_encode, METH_FASTCALL, _codecs_oem_encode__doc__}, static PyObject * _codecs_oem_encode_impl(PyObject *module, PyObject *str, const char *errors); @@ -2725,39 +2725,39 @@ _codecs_oem_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("oem_encode", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("oem_encode", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - str = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("oem_encode", "argument 2", "str or None", args[1]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("oem_encode", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("oem_encode", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + str = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("oem_encode", "argument 2", "str or None", args[1]); + goto exit; + } +skip_optional: return_value = _codecs_oem_encode_impl(module, str, errors); exit: @@ -2774,7 +2774,7 @@ PyDoc_STRVAR(_codecs_code_page_encode__doc__, "\n"); #define _CODECS_CODE_PAGE_ENCODE_METHODDEF \ - {"code_page_encode", (PyCFunction)(void(*)(void))_codecs_code_page_encode, METH_FASTCALL, _codecs_code_page_encode__doc__}, + {"code_page_encode", (PyCFunction)(void(*)(void))_codecs_code_page_encode, METH_FASTCALL, _codecs_code_page_encode__doc__}, static PyObject * _codecs_code_page_encode_impl(PyObject *module, int code_page, PyObject *str, @@ -2788,48 +2788,48 @@ _codecs_code_page_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar PyObject *str; const char *errors = NULL; - if (!_PyArg_CheckPositional("code_page_encode", nargs, 2, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code_page = _PyLong_AsInt(args[0]); - if (code_page == -1 && PyErr_Occurred()) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("code_page_encode", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - str = args[1]; - if (nargs < 3) { - goto skip_optional; - } - if (args[2] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("code_page_encode", "argument 3", "str or None", args[2]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("code_page_encode", nargs, 2, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + code_page = _PyLong_AsInt(args[0]); + if (code_page == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("code_page_encode", "argument 2", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + str = args[1]; + if (nargs < 3) { + goto skip_optional; + } + if (args[2] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[2])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("code_page_encode", "argument 3", "str or None", args[2]); + goto exit; + } +skip_optional: return_value = _codecs_code_page_encode_impl(module, code_page, str, errors); exit: @@ -2849,7 +2849,7 @@ PyDoc_STRVAR(_codecs_register_error__doc__, "error and must return a (replacement, new position) tuple."); #define _CODECS_REGISTER_ERROR_METHODDEF \ - {"register_error", (PyCFunction)(void(*)(void))_codecs_register_error, METH_FASTCALL, _codecs_register_error__doc__}, + {"register_error", (PyCFunction)(void(*)(void))_codecs_register_error, METH_FASTCALL, _codecs_register_error__doc__}, static PyObject * _codecs_register_error_impl(PyObject *module, const char *errors, @@ -2862,23 +2862,23 @@ _codecs_register_error(PyObject *module, PyObject *const *args, Py_ssize_t nargs const char *errors; PyObject *handler; - if (!_PyArg_CheckPositional("register_error", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("register_error", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[0], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - handler = args[1]; + if (!_PyArg_CheckPositional("register_error", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("register_error", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[0], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + handler = args[1]; return_value = _codecs_register_error_impl(module, errors, handler); exit: @@ -2906,19 +2906,19 @@ _codecs_lookup_error(PyObject *module, PyObject *arg) PyObject *return_value = NULL; const char *name; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("lookup_error", "argument", "str", arg); - goto exit; - } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("lookup_error", "argument", "str", arg); goto exit; } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(arg, &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _codecs_lookup_error_impl(module, name); exit: @@ -2948,4 +2948,4 @@ exit: #ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF #define _CODECS_CODE_PAGE_ENCODE_METHODDEF #endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=eed7dc9312baf252 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eed7dc9312baf252 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_collectionsmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_collectionsmodule.c.h index c3ba1a6698..fd2ef8d418 100644 --- a/contrib/tools/python3/src/Modules/clinic/_collectionsmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_collectionsmodule.c.h @@ -1,76 +1,76 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_collections__count_elements__doc__, -"_count_elements($module, mapping, iterable, /)\n" -"--\n" -"\n" -"Count elements in the iterable, updating the mapping"); - -#define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF \ - {"_count_elements", (PyCFunction)(void(*)(void))_collections__count_elements, METH_FASTCALL, _collections__count_elements__doc__}, - -static PyObject * -_collections__count_elements_impl(PyObject *module, PyObject *mapping, - PyObject *iterable); - -static PyObject * -_collections__count_elements(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *mapping; - PyObject *iterable; - - if (!_PyArg_CheckPositional("_count_elements", nargs, 2, 2)) { - goto exit; - } - mapping = args[0]; - iterable = args[1]; - return_value = _collections__count_elements_impl(module, mapping, iterable); - -exit: - return return_value; -} - -static PyObject * -tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc); - -static PyObject * -tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - Py_ssize_t index; - PyObject *doc; - - if ((type == &tuplegetter_type) && - !_PyArg_NoKeywords("_tuplegetter", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0)); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - index = ival; - } - doc = PyTuple_GET_ITEM(args, 1); - return_value = tuplegetter_new_impl(type, index, doc); - -exit: - return return_value; -} -/*[clinic end generated code: output=9d2bfcc9df5faf35 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_collections__count_elements__doc__, +"_count_elements($module, mapping, iterable, /)\n" +"--\n" +"\n" +"Count elements in the iterable, updating the mapping"); + +#define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF \ + {"_count_elements", (PyCFunction)(void(*)(void))_collections__count_elements, METH_FASTCALL, _collections__count_elements__doc__}, + +static PyObject * +_collections__count_elements_impl(PyObject *module, PyObject *mapping, + PyObject *iterable); + +static PyObject * +_collections__count_elements(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *mapping; + PyObject *iterable; + + if (!_PyArg_CheckPositional("_count_elements", nargs, 2, 2)) { + goto exit; + } + mapping = args[0]; + iterable = args[1]; + return_value = _collections__count_elements_impl(module, mapping, iterable); + +exit: + return return_value; +} + +static PyObject * +tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc); + +static PyObject * +tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + Py_ssize_t index; + PyObject *doc; + + if ((type == &tuplegetter_type) && + !_PyArg_NoKeywords("_tuplegetter", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0)); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + index = ival; + } + doc = PyTuple_GET_ITEM(args, 1); + return_value = tuplegetter_new_impl(type, index, doc); + +exit: + return return_value; +} +/*[clinic end generated code: output=9d2bfcc9df5faf35 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_cryptmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_cryptmodule.c.h index ea91d7c130..a4de347bc8 100644 --- a/contrib/tools/python3/src/Modules/clinic/_cryptmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_cryptmodule.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(crypt_crypt__doc__, "results for a given *word*."); #define CRYPT_CRYPT_METHODDEF \ - {"crypt", (PyCFunction)(void(*)(void))crypt_crypt, METH_FASTCALL, crypt_crypt__doc__}, + {"crypt", (PyCFunction)(void(*)(void))crypt_crypt, METH_FASTCALL, crypt_crypt__doc__}, static PyObject * crypt_crypt_impl(PyObject *module, const char *word, const char *salt); @@ -26,38 +26,38 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *word; const char *salt; - if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("crypt", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t word_length; - word = PyUnicode_AsUTF8AndSize(args[0], &word_length); - if (word == NULL) { - goto exit; - } - if (strlen(word) != (size_t)word_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("crypt", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t salt_length; - salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length); - if (salt == NULL) { - goto exit; - } - if (strlen(salt) != (size_t)salt_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("crypt", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t word_length; + word = PyUnicode_AsUTF8AndSize(args[0], &word_length); + if (word == NULL) { + goto exit; + } + if (strlen(word) != (size_t)word_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("crypt", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t salt_length; + salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length); + if (salt == NULL) { + goto exit; + } + if (strlen(salt) != (size_t)salt_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = crypt_crypt_impl(module, word, salt); exit: return return_value; } -/*[clinic end generated code: output=549de0d43b030126 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=549de0d43b030126 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h b/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h index 9840ed86e7..9bb51f2880 100644 --- a/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h @@ -1,338 +1,338 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, -"bottom($self, /)\n" -"--\n" -"\n" -"Push the panel to the bottom of the stack."); - -#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ - {"bottom", (PyCFunction)_curses_panel_panel_bottom, METH_NOARGS, _curses_panel_panel_bottom__doc__}, - -static PyObject * -_curses_panel_panel_bottom_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_bottom(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_bottom_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_hide__doc__, -"hide($self, /)\n" -"--\n" -"\n" -"Hide the panel.\n" -"\n" -"This does not delete the object, it just makes the window on screen invisible."); - -#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ - {"hide", (PyCFunction)_curses_panel_panel_hide, METH_NOARGS, _curses_panel_panel_hide__doc__}, - -static PyObject * -_curses_panel_panel_hide_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_hide(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_hide_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_show__doc__, -"show($self, /)\n" -"--\n" -"\n" -"Display the panel (which might have been hidden)."); - -#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ - {"show", (PyCFunction)_curses_panel_panel_show, METH_NOARGS, _curses_panel_panel_show__doc__}, - -static PyObject * -_curses_panel_panel_show_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_show(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_show_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_top__doc__, -"top($self, /)\n" -"--\n" -"\n" -"Push panel to the top of the stack."); - -#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ - {"top", (PyCFunction)_curses_panel_panel_top, METH_NOARGS, _curses_panel_panel_top__doc__}, - -static PyObject * -_curses_panel_panel_top_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_top(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_top_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_above__doc__, -"above($self, /)\n" -"--\n" -"\n" -"Return the panel above the current panel."); - -#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ - {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, - -static PyObject * -_curses_panel_panel_above_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_above_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_below__doc__, -"below($self, /)\n" -"--\n" -"\n" -"Return the panel below the current panel."); - -#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ - {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, - -static PyObject * -_curses_panel_panel_below_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_below_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, -"hidden($self, /)\n" -"--\n" -"\n" -"Return True if the panel is hidden (not visible), False otherwise."); - -#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ - {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, - -static PyObject * -_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_hidden_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_move__doc__, -"move($self, y, x, /)\n" -"--\n" -"\n" -"Move the panel to the screen coordinates (y, x)."); - -#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ - {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_FASTCALL, _curses_panel_panel_move__doc__}, - -static PyObject * -_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x); - -static PyObject * -_curses_panel_panel_move(PyCursesPanelObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int y; - int x; - - if (!_PyArg_CheckPositional("move", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - y = _PyLong_AsInt(args[0]); - if (y == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - x = _PyLong_AsInt(args[1]); - if (x == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_panel_panel_move_impl(self, y, x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_window__doc__, -"window($self, /)\n" -"--\n" -"\n" -"Return the window object associated with the panel."); - -#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ - {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, - -static PyObject * -_curses_panel_panel_window_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_window_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_replace__doc__, -"replace($self, win, /)\n" -"--\n" -"\n" -"Change the window associated with the panel to the window win."); - -#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ - {"replace", (PyCFunction)_curses_panel_panel_replace, METH_O, _curses_panel_panel_replace__doc__}, - -static PyObject * -_curses_panel_panel_replace_impl(PyCursesPanelObject *self, - PyCursesWindowObject *win); - -static PyObject * -_curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *win; - - if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { - _PyArg_BadArgument("replace", "argument", (&PyCursesWindow_Type)->tp_name, arg); - goto exit; - } - win = (PyCursesWindowObject *)arg; - return_value = _curses_panel_panel_replace_impl(self, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, -"set_userptr($self, obj, /)\n" -"--\n" -"\n" -"Set the panel\'s user pointer to obj."); - -#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ - {"set_userptr", (PyCFunction)_curses_panel_panel_set_userptr, METH_O, _curses_panel_panel_set_userptr__doc__}, - -PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, -"userptr($self, /)\n" -"--\n" -"\n" -"Return the user pointer for the panel."); - -#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ - {"userptr", (PyCFunction)_curses_panel_panel_userptr, METH_NOARGS, _curses_panel_panel_userptr__doc__}, - -static PyObject * -_curses_panel_panel_userptr_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_userptr(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_userptr_impl(self); -} - -PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, -"bottom_panel($module, /)\n" -"--\n" -"\n" -"Return the bottom panel in the panel stack."); - -#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ - {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, - -static PyObject * -_curses_panel_bottom_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_bottom_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_new_panel__doc__, -"new_panel($module, win, /)\n" -"--\n" -"\n" -"Return a panel object, associating it with the given window win."); - -#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ - {"new_panel", (PyCFunction)_curses_panel_new_panel, METH_O, _curses_panel_new_panel__doc__}, - -static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win); - -static PyObject * -_curses_panel_new_panel(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *win; - - if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { - _PyArg_BadArgument("new_panel", "argument", (&PyCursesWindow_Type)->tp_name, arg); - goto exit; - } - win = (PyCursesWindowObject *)arg; - return_value = _curses_panel_new_panel_impl(module, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_top_panel__doc__, -"top_panel($module, /)\n" -"--\n" -"\n" -"Return the top panel in the panel stack."); - -#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ - {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, - -static PyObject * -_curses_panel_top_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_top_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_update_panels__doc__, -"update_panels($module, /)\n" -"--\n" -"\n" -"Updates the virtual screen after changes in the panel stack.\n" -"\n" -"This does not call curses.doupdate(), so you\'ll have to do this yourself."); - -#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ - {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, - -static PyObject * -_curses_panel_update_panels_impl(PyObject *module); - -static PyObject * -_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_update_panels_impl(module); -} -/*[clinic end generated code: output=d96dc1fd68e898d9 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, +"bottom($self, /)\n" +"--\n" +"\n" +"Push the panel to the bottom of the stack."); + +#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ + {"bottom", (PyCFunction)_curses_panel_panel_bottom, METH_NOARGS, _curses_panel_panel_bottom__doc__}, + +static PyObject * +_curses_panel_panel_bottom_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_bottom(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_bottom_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_hide__doc__, +"hide($self, /)\n" +"--\n" +"\n" +"Hide the panel.\n" +"\n" +"This does not delete the object, it just makes the window on screen invisible."); + +#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ + {"hide", (PyCFunction)_curses_panel_panel_hide, METH_NOARGS, _curses_panel_panel_hide__doc__}, + +static PyObject * +_curses_panel_panel_hide_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_hide(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_hide_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_show__doc__, +"show($self, /)\n" +"--\n" +"\n" +"Display the panel (which might have been hidden)."); + +#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ + {"show", (PyCFunction)_curses_panel_panel_show, METH_NOARGS, _curses_panel_panel_show__doc__}, + +static PyObject * +_curses_panel_panel_show_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_show(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_show_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_top__doc__, +"top($self, /)\n" +"--\n" +"\n" +"Push panel to the top of the stack."); + +#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ + {"top", (PyCFunction)_curses_panel_panel_top, METH_NOARGS, _curses_panel_panel_top__doc__}, + +static PyObject * +_curses_panel_panel_top_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_top(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_top_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_above__doc__, +"above($self, /)\n" +"--\n" +"\n" +"Return the panel above the current panel."); + +#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ + {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, + +static PyObject * +_curses_panel_panel_above_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_above_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_below__doc__, +"below($self, /)\n" +"--\n" +"\n" +"Return the panel below the current panel."); + +#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ + {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, + +static PyObject * +_curses_panel_panel_below_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_below_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, +"hidden($self, /)\n" +"--\n" +"\n" +"Return True if the panel is hidden (not visible), False otherwise."); + +#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ + {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, + +static PyObject * +_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_hidden_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_move__doc__, +"move($self, y, x, /)\n" +"--\n" +"\n" +"Move the panel to the screen coordinates (y, x)."); + +#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ + {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_FASTCALL, _curses_panel_panel_move__doc__}, + +static PyObject * +_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x); + +static PyObject * +_curses_panel_panel_move(PyCursesPanelObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int y; + int x; + + if (!_PyArg_CheckPositional("move", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + y = _PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + x = _PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_panel_panel_move_impl(self, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_window__doc__, +"window($self, /)\n" +"--\n" +"\n" +"Return the window object associated with the panel."); + +#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ + {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, + +static PyObject * +_curses_panel_panel_window_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_window_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_replace__doc__, +"replace($self, win, /)\n" +"--\n" +"\n" +"Change the window associated with the panel to the window win."); + +#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ + {"replace", (PyCFunction)_curses_panel_panel_replace, METH_O, _curses_panel_panel_replace__doc__}, + +static PyObject * +_curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *win; + + if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { + _PyArg_BadArgument("replace", "argument", (&PyCursesWindow_Type)->tp_name, arg); + goto exit; + } + win = (PyCursesWindowObject *)arg; + return_value = _curses_panel_panel_replace_impl(self, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, +"set_userptr($self, obj, /)\n" +"--\n" +"\n" +"Set the panel\'s user pointer to obj."); + +#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ + {"set_userptr", (PyCFunction)_curses_panel_panel_set_userptr, METH_O, _curses_panel_panel_set_userptr__doc__}, + +PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, +"userptr($self, /)\n" +"--\n" +"\n" +"Return the user pointer for the panel."); + +#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ + {"userptr", (PyCFunction)_curses_panel_panel_userptr, METH_NOARGS, _curses_panel_panel_userptr__doc__}, + +static PyObject * +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_userptr(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_userptr_impl(self); +} + +PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, +"bottom_panel($module, /)\n" +"--\n" +"\n" +"Return the bottom panel in the panel stack."); + +#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ + {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, + +static PyObject * +_curses_panel_bottom_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_bottom_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_new_panel__doc__, +"new_panel($module, win, /)\n" +"--\n" +"\n" +"Return a panel object, associating it with the given window win."); + +#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ + {"new_panel", (PyCFunction)_curses_panel_new_panel, METH_O, _curses_panel_new_panel__doc__}, + +static PyObject * +_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win); + +static PyObject * +_curses_panel_new_panel(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *win; + + if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { + _PyArg_BadArgument("new_panel", "argument", (&PyCursesWindow_Type)->tp_name, arg); + goto exit; + } + win = (PyCursesWindowObject *)arg; + return_value = _curses_panel_new_panel_impl(module, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_top_panel__doc__, +"top_panel($module, /)\n" +"--\n" +"\n" +"Return the top panel in the panel stack."); + +#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ + {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, + +static PyObject * +_curses_panel_top_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_top_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_update_panels__doc__, +"update_panels($module, /)\n" +"--\n" +"\n" +"Updates the virtual screen after changes in the panel stack.\n" +"\n" +"This does not call curses.doupdate(), so you\'ll have to do this yourself."); + +#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ + {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, + +static PyObject * +_curses_panel_update_panels_impl(PyObject *module); + +static PyObject * +_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_update_panels_impl(module); +} +/*[clinic end generated code: output=d96dc1fd68e898d9 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_cursesmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_cursesmodule.c.h index 66ffcdfdb3..d9ed058c57 100644 --- a/contrib/tools/python3/src/Modules/clinic/_cursesmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_cursesmodule.c.h @@ -2,9 +2,9 @@ preserve [clinic start generated code]*/ -PyDoc_STRVAR(_curses_window_addch__doc__, -"addch([y, x,] ch, [attr=_curses.A_NORMAL])\n" -"Paint the character.\n" +PyDoc_STRVAR(_curses_window_addch__doc__, +"addch([y, x,] ch, [attr=_curses.A_NORMAL])\n" +"Paint the character.\n" "\n" " y\n" " Y-coordinate.\n" @@ -20,16 +20,16 @@ PyDoc_STRVAR(_curses_window_addch__doc__, "By default, the character position and attributes are the\n" "current settings for the window object."); -#define _CURSES_WINDOW_ADDCH_METHODDEF \ - {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__}, +#define _CURSES_WINDOW_ADDCH_METHODDEF \ + {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__}, static PyObject * -_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *ch, int group_right_1, - long attr); +_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int group_right_1, + long attr); static PyObject * -_curses_window_addch(PyCursesWindowObject *self, PyObject *args) +_curses_window_addch(PyCursesWindowObject *self, PyObject *args) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -37,7 +37,7 @@ _curses_window_addch(PyCursesWindowObject *self, PyObject *args) int x = 0; PyObject *ch; int group_right_1 = 0; - long attr = A_NORMAL; + long attr = A_NORMAL; switch (PyTuple_GET_SIZE(args)) { case 1: @@ -65,4652 +65,4652 @@ _curses_window_addch(PyCursesWindowObject *self, PyObject *args) group_left_1 = 1; break; default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments"); + PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments"); goto exit; } - return_value = _curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); + return_value = _curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); exit: return return_value; } - -PyDoc_STRVAR(_curses_window_addstr__doc__, -"addstr([y, x,] str, [attr])\n" -"Paint the string.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" str\n" -" String to add.\n" -" attr\n" -" Attributes for characters.\n" -"\n" -"Paint the string str at (y, x) with attributes attr,\n" -"overwriting anything previously on the display.\n" -"By default, the character position and attributes are the\n" -"current settings for the window object."); - -#define _CURSES_WINDOW_ADDSTR_METHODDEF \ - {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__}, - -static PyObject * -_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *str, int group_right_1, - long attr); - -static PyObject * -_curses_window_addstr(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *str; - int group_right_1 = 0; - long attr = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:addstr", &str)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); - goto exit; - } - return_value = _curses_window_addstr_impl(self, group_left_1, y, x, str, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_addnstr__doc__, -"addnstr([y, x,] str, n, [attr])\n" -"Paint at most n characters of the string.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" str\n" -" String to add.\n" -" n\n" -" Maximal number of characters.\n" -" attr\n" -" Attributes for characters.\n" -"\n" -"Paint at most n characters of the string str at (y, x) with\n" -"attributes attr, overwriting anything previously on the display.\n" -"By default, the character position and attributes are the\n" -"current settings for the window object."); - -#define _CURSES_WINDOW_ADDNSTR_METHODDEF \ - {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__}, - -static PyObject * -_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *str, int n, - int group_right_1, long attr); - -static PyObject * -_curses_window_addnstr(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *str; - int n; - int group_right_1 = 0; - long attr = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); - goto exit; - } - return_value = _curses_window_addnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_bkgd__doc__, -"bkgd($self, ch, attr=_curses.A_NORMAL, /)\n" -"--\n" -"\n" -"Set the background property of the window.\n" -"\n" -" ch\n" -" Background character.\n" -" attr\n" -" Background attributes."); - -#define _CURSES_WINDOW_BKGD_METHODDEF \ - {"bkgd", (PyCFunction)(void(*)(void))_curses_window_bkgd, METH_FASTCALL, _curses_window_bkgd__doc__}, - -static PyObject * -_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr); - -static PyObject * -_curses_window_bkgd(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *ch; - long attr = A_NORMAL; - - if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) { - goto exit; - } - ch = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(args[1]); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_window_bkgd_impl(self, ch, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_attroff__doc__, -"attroff($self, attr, /)\n" -"--\n" -"\n" -"Remove attribute attr from the \"background\" set."); - -#define _CURSES_WINDOW_ATTROFF_METHODDEF \ - {"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__}, - -static PyObject * -_curses_window_attroff_impl(PyCursesWindowObject *self, long attr); - -static PyObject * -_curses_window_attroff(PyCursesWindowObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - long attr; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_attroff_impl(self, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_attron__doc__, -"attron($self, attr, /)\n" -"--\n" -"\n" -"Add attribute attr from the \"background\" set."); - -#define _CURSES_WINDOW_ATTRON_METHODDEF \ - {"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__}, - -static PyObject * -_curses_window_attron_impl(PyCursesWindowObject *self, long attr); - -static PyObject * -_curses_window_attron(PyCursesWindowObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - long attr; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_attron_impl(self, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_attrset__doc__, -"attrset($self, attr, /)\n" -"--\n" -"\n" -"Set the \"background\" set of attributes."); - -#define _CURSES_WINDOW_ATTRSET_METHODDEF \ - {"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__}, - -static PyObject * -_curses_window_attrset_impl(PyCursesWindowObject *self, long attr); - -static PyObject * -_curses_window_attrset(PyCursesWindowObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - long attr; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_attrset_impl(self, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_bkgdset__doc__, -"bkgdset($self, ch, attr=_curses.A_NORMAL, /)\n" -"--\n" -"\n" -"Set the window\'s background.\n" -"\n" -" ch\n" -" Background character.\n" -" attr\n" -" Background attributes."); - -#define _CURSES_WINDOW_BKGDSET_METHODDEF \ - {"bkgdset", (PyCFunction)(void(*)(void))_curses_window_bkgdset, METH_FASTCALL, _curses_window_bkgdset__doc__}, - -static PyObject * -_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, - long attr); - -static PyObject * -_curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *ch; - long attr = A_NORMAL; - - if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) { - goto exit; - } - ch = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(args[1]); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_window_bkgdset_impl(self, ch, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_border__doc__, -"border($self, ls=_curses.ACS_VLINE, rs=_curses.ACS_VLINE,\n" -" ts=_curses.ACS_HLINE, bs=_curses.ACS_HLINE,\n" -" tl=_curses.ACS_ULCORNER, tr=_curses.ACS_URCORNER,\n" -" bl=_curses.ACS_LLCORNER, br=_curses.ACS_LRCORNER, /)\n" -"--\n" -"\n" -"Draw a border around the edges of the window.\n" -"\n" -" ls\n" -" Left side.\n" -" rs\n" -" Right side.\n" -" ts\n" -" Top side.\n" -" bs\n" -" Bottom side.\n" -" tl\n" -" Upper-left corner.\n" -" tr\n" -" Upper-right corner.\n" -" bl\n" -" Bottom-left corner.\n" -" br\n" -" Bottom-right corner.\n" -"\n" -"Each parameter specifies the character to use for a specific part of the\n" -"border. The characters can be specified as integers or as one-character\n" -"strings. A 0 value for any parameter will cause the default character to be\n" -"used for that parameter."); - -#define _CURSES_WINDOW_BORDER_METHODDEF \ - {"border", (PyCFunction)(void(*)(void))_curses_window_border, METH_FASTCALL, _curses_window_border__doc__}, - -static PyObject * -_curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, - PyObject *rs, PyObject *ts, PyObject *bs, - PyObject *tl, PyObject *tr, PyObject *bl, - PyObject *br); - -static PyObject * -_curses_window_border(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *ls = NULL; - PyObject *rs = NULL; - PyObject *ts = NULL; - PyObject *bs = NULL; - PyObject *tl = NULL; - PyObject *tr = NULL; - PyObject *bl = NULL; - PyObject *br = NULL; - - if (!_PyArg_CheckPositional("border", nargs, 0, 8)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - ls = args[0]; - if (nargs < 2) { - goto skip_optional; - } - rs = args[1]; - if (nargs < 3) { - goto skip_optional; - } - ts = args[2]; - if (nargs < 4) { - goto skip_optional; - } - bs = args[3]; - if (nargs < 5) { - goto skip_optional; - } - tl = args[4]; - if (nargs < 6) { - goto skip_optional; - } - tr = args[5]; - if (nargs < 7) { - goto skip_optional; - } - bl = args[6]; - if (nargs < 8) { - goto skip_optional; - } - br = args[7]; -skip_optional: - return_value = _curses_window_border_impl(self, ls, rs, ts, bs, tl, tr, bl, br); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_box__doc__, -"box([verch=0, horch=0])\n" -"Draw a border around the edges of the window.\n" -"\n" -" verch\n" -" Left and right side.\n" -" horch\n" -" Top and bottom side.\n" -"\n" -"Similar to border(), but both ls and rs are verch and both ts and bs are\n" -"horch. The default corner characters are always used by this function."); - -#define _CURSES_WINDOW_BOX_METHODDEF \ - {"box", (PyCFunction)_curses_window_box, METH_VARARGS, _curses_window_box__doc__}, - -static PyObject * -_curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, - PyObject *verch, PyObject *horch); - -static PyObject * -_curses_window_box(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - PyObject *verch = _PyLong_Zero; - PyObject *horch = _PyLong_Zero; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "OO:box", &verch, &horch)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.box requires 0 to 2 arguments"); - goto exit; - } - return_value = _curses_window_box_impl(self, group_right_1, verch, horch); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_delch__doc__, -"delch([y, x])\n" -"Delete any character at (y, x).\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate."); - -#define _CURSES_WINDOW_DELCH_METHODDEF \ - {"delch", (PyCFunction)_curses_window_delch, METH_VARARGS, _curses_window_delch__doc__}, - -static PyObject * -_curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1, - int y, int x); - -static PyObject * -_curses_window_delch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int y = 0; - int x = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:delch", &y, &x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.delch requires 0 to 2 arguments"); - goto exit; - } - return_value = _curses_window_delch_impl(self, group_right_1, y, x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_derwin__doc__, -"derwin([nlines=0, ncols=0,] begin_y, begin_x)\n" -"Create a sub-window (window-relative coordinates).\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width.\n" -" begin_y\n" -" Top side y-coordinate.\n" -" begin_x\n" -" Left side x-coordinate.\n" -"\n" -"derwin() is the same as calling subwin(), except that begin_y and begin_x\n" -"are relative to the origin of the window, rather than relative to the entire\n" -"screen."); - -#define _CURSES_WINDOW_DERWIN_METHODDEF \ - {"derwin", (PyCFunction)_curses_window_derwin, METH_VARARGS, _curses_window_derwin__doc__}, - -static PyObject * -_curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, - int nlines, int ncols, int begin_y, int begin_x); - -static PyObject * -_curses_window_derwin(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int nlines = 0; - int ncols = 0; - int begin_y; - int begin_x; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "ii:derwin", &begin_y, &begin_x)) { - goto exit; - } - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii:derwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.derwin requires 2 to 4 arguments"); - goto exit; - } - return_value = _curses_window_derwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_echochar__doc__, -"echochar($self, ch, attr=_curses.A_NORMAL, /)\n" -"--\n" -"\n" -"Add character ch with attribute attr, and refresh.\n" -"\n" -" ch\n" -" Character to add.\n" -" attr\n" -" Attributes for the character."); - -#define _CURSES_WINDOW_ECHOCHAR_METHODDEF \ - {"echochar", (PyCFunction)(void(*)(void))_curses_window_echochar, METH_FASTCALL, _curses_window_echochar__doc__}, - -static PyObject * -_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, - long attr); - -static PyObject * -_curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *ch; - long attr = A_NORMAL; - - if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) { - goto exit; - } - ch = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = PyLong_AsLong(args[1]); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_window_echochar_impl(self, ch, attr); - -exit: - return return_value; -} - -#if defined(NCURSES_MOUSE_VERSION) - -PyDoc_STRVAR(_curses_window_enclose__doc__, -"enclose($self, y, x, /)\n" -"--\n" -"\n" -"Return True if the screen-relative coordinates are enclosed by the window.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate."); - -#define _CURSES_WINDOW_ENCLOSE_METHODDEF \ - {"enclose", (PyCFunction)(void(*)(void))_curses_window_enclose, METH_FASTCALL, _curses_window_enclose__doc__}, - -static long -_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x); - -static PyObject * -_curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int y; - int x; - long _return_value; - - if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - y = _PyLong_AsInt(args[0]); - if (y == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - x = _PyLong_AsInt(args[1]); - if (x == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = _curses_window_enclose_impl(self, y, x); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -#endif /* defined(NCURSES_MOUSE_VERSION) */ - -PyDoc_STRVAR(_curses_window_getbkgd__doc__, -"getbkgd($self, /)\n" -"--\n" -"\n" -"Return the window\'s current background character/attribute pair."); - -#define _CURSES_WINDOW_GETBKGD_METHODDEF \ - {"getbkgd", (PyCFunction)_curses_window_getbkgd, METH_NOARGS, _curses_window_getbkgd__doc__}, - -static long -_curses_window_getbkgd_impl(PyCursesWindowObject *self); - -static PyObject * -_curses_window_getbkgd(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - long _return_value; - - _return_value = _curses_window_getbkgd_impl(self); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_getch__doc__, -"getch([y, x])\n" -"Get a character code from terminal keyboard.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -"\n" -"The integer returned does not have to be in ASCII range: function keys,\n" -"keypad keys and so on return numbers higher than 256. In no-delay mode, -1\n" -"is returned if there is no input, else getch() waits until a key is pressed."); - -#define _CURSES_WINDOW_GETCH_METHODDEF \ - {"getch", (PyCFunction)_curses_window_getch, METH_VARARGS, _curses_window_getch__doc__}, - -static int -_curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, - int y, int x); - -static PyObject * -_curses_window_getch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int y = 0; - int x = 0; - int _return_value; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:getch", &y, &x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.getch requires 0 to 2 arguments"); - goto exit; - } - _return_value = _curses_window_getch_impl(self, group_right_1, y, x); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_getkey__doc__, -"getkey([y, x])\n" -"Get a character (string) from terminal keyboard.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -"\n" -"Returning a string instead of an integer, as getch() does. Function keys,\n" -"keypad keys and other special keys return a multibyte string containing the\n" -"key name. In no-delay mode, an exception is raised if there is no input."); - -#define _CURSES_WINDOW_GETKEY_METHODDEF \ - {"getkey", (PyCFunction)_curses_window_getkey, METH_VARARGS, _curses_window_getkey__doc__}, - -static PyObject * -_curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, - int y, int x); - -static PyObject * -_curses_window_getkey(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int y = 0; - int x = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:getkey", &y, &x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.getkey requires 0 to 2 arguments"); - goto exit; - } - return_value = _curses_window_getkey_impl(self, group_right_1, y, x); - -exit: - return return_value; -} - -#if defined(HAVE_NCURSESW) - -PyDoc_STRVAR(_curses_window_get_wch__doc__, -"get_wch([y, x])\n" -"Get a wide character from terminal keyboard.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -"\n" -"Return a character for most keys, or an integer for function keys,\n" -"keypad keys, and other special keys."); - -#define _CURSES_WINDOW_GET_WCH_METHODDEF \ - {"get_wch", (PyCFunction)_curses_window_get_wch, METH_VARARGS, _curses_window_get_wch__doc__}, - -static PyObject * -_curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, - int y, int x); - -static PyObject * -_curses_window_get_wch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int y = 0; - int x = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:get_wch", &y, &x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.get_wch requires 0 to 2 arguments"); - goto exit; - } - return_value = _curses_window_get_wch_impl(self, group_right_1, y, x); - -exit: - return return_value; -} - -#endif /* defined(HAVE_NCURSESW) */ - -PyDoc_STRVAR(_curses_window_hline__doc__, -"hline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n" -"Display a horizontal line.\n" -"\n" -" y\n" -" Starting Y-coordinate.\n" -" x\n" -" Starting X-coordinate.\n" -" ch\n" -" Character to draw.\n" -" n\n" -" Line length.\n" -" attr\n" -" Attributes for the characters."); - -#define _CURSES_WINDOW_HLINE_METHODDEF \ - {"hline", (PyCFunction)_curses_window_hline, METH_VARARGS, _curses_window_hline__doc__}, - -static PyObject * -_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *ch, int n, - int group_right_1, long attr); - -static PyObject * -_curses_window_hline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *ch; - int n; - int group_right_1 = 0; - long attr = A_NORMAL; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:hline", &ch, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil:hline", &ch, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:hline", &y, &x, &ch, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments"); - goto exit; - } - return_value = _curses_window_hline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_insch__doc__, -"insch([y, x,] ch, [attr=_curses.A_NORMAL])\n" -"Insert a character before the current or specified position.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" ch\n" -" Character to insert.\n" -" attr\n" -" Attributes for the character.\n" -"\n" -"All characters to the right of the cursor are shifted one position right, with\n" -"the rightmost characters on the line being lost."); - -#define _CURSES_WINDOW_INSCH_METHODDEF \ - {"insch", (PyCFunction)_curses_window_insch, METH_VARARGS, _curses_window_insch__doc__}, - -static PyObject * -_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *ch, int group_right_1, - long attr); - -static PyObject * -_curses_window_insch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *ch; - int group_right_1 = 0; - long attr = A_NORMAL; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:insch", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol:insch", &ch, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:insch", &y, &x, &ch)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments"); - goto exit; - } - return_value = _curses_window_insch_impl(self, group_left_1, y, x, ch, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_inch__doc__, -"inch([y, x])\n" -"Return the character at the given position in the window.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -"\n" -"The bottom 8 bits are the character proper, and upper bits are the attributes."); - -#define _CURSES_WINDOW_INCH_METHODDEF \ - {"inch", (PyCFunction)_curses_window_inch, METH_VARARGS, _curses_window_inch__doc__}, - -static unsigned long -_curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, - int y, int x); - -static PyObject * -_curses_window_inch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int y = 0; - int x = 0; - unsigned long _return_value; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:inch", &y, &x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.inch requires 0 to 2 arguments"); - goto exit; - } - _return_value = _curses_window_inch_impl(self, group_right_1, y, x); - if ((_return_value == (unsigned long)-1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromUnsignedLong(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_insstr__doc__, -"insstr([y, x,] str, [attr])\n" -"Insert the string before the current or specified position.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" str\n" -" String to insert.\n" -" attr\n" -" Attributes for characters.\n" -"\n" -"Insert a character string (as many characters as will fit on the line)\n" -"before the character under the cursor. All characters to the right of\n" -"the cursor are shifted right, with the rightmost characters on the line\n" -"being lost. The cursor position does not change (after moving to y, x,\n" -"if specified)."); - -#define _CURSES_WINDOW_INSSTR_METHODDEF \ - {"insstr", (PyCFunction)_curses_window_insstr, METH_VARARGS, _curses_window_insstr__doc__}, - -static PyObject * -_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *str, int group_right_1, - long attr); - -static PyObject * -_curses_window_insstr(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *str; - int group_right_1 = 0; - long attr = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:insstr", &str)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol:insstr", &str, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:insstr", &y, &x, &str)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); - goto exit; - } - return_value = _curses_window_insstr_impl(self, group_left_1, y, x, str, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_insnstr__doc__, -"insnstr([y, x,] str, n, [attr])\n" -"Insert at most n characters of the string.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" str\n" -" String to insert.\n" -" n\n" -" Maximal number of characters.\n" -" attr\n" -" Attributes for characters.\n" -"\n" -"Insert a character string (as many characters as will fit on the line)\n" -"before the character under the cursor, up to n characters. If n is zero\n" -"or negative, the entire string is inserted. All characters to the right\n" -"of the cursor are shifted right, with the rightmost characters on the line\n" -"being lost. The cursor position does not change (after moving to y, x, if\n" -"specified)."); - -#define _CURSES_WINDOW_INSNSTR_METHODDEF \ - {"insnstr", (PyCFunction)_curses_window_insnstr, METH_VARARGS, _curses_window_insnstr__doc__}, - -static PyObject * -_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *str, int n, - int group_right_1, long attr); - -static PyObject * -_curses_window_insnstr(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *str; - int n; - int group_right_1 = 0; - long attr = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:insnstr", &str, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil:insnstr", &str, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:insnstr", &y, &x, &str, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); - goto exit; - } - return_value = _curses_window_insnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_is_linetouched__doc__, -"is_linetouched($self, line, /)\n" -"--\n" -"\n" -"Return True if the specified line was modified, otherwise return False.\n" -"\n" -" line\n" -" Line number.\n" -"\n" -"Raise a curses.error exception if line is not valid for the given window."); - -#define _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF \ - {"is_linetouched", (PyCFunction)_curses_window_is_linetouched, METH_O, _curses_window_is_linetouched__doc__}, - -static PyObject * -_curses_window_is_linetouched_impl(PyCursesWindowObject *self, int line); - -static PyObject * -_curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int line; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - line = _PyLong_AsInt(arg); - if (line == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_is_linetouched_impl(self, line); - -exit: - return return_value; -} - -#if defined(py_is_pad) - -PyDoc_STRVAR(_curses_window_noutrefresh__doc__, -"noutrefresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" -"Mark for refresh but wait.\n" -"\n" -"This function updates the data structure representing the desired state of the\n" -"window, but does not force an update of the physical screen. To accomplish\n" -"that, call doupdate()."); - -#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ - {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_VARARGS, _curses_window_noutrefresh__doc__}, - -static PyObject * -_curses_window_noutrefresh_impl(PyCursesWindowObject *self, - int group_right_1, int pminrow, int pmincol, - int sminrow, int smincol, int smaxrow, - int smaxcol); - -static PyObject * -_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int pminrow = 0; - int pmincol = 0; - int sminrow = 0; - int smincol = 0; - int smaxrow = 0; - int smaxcol = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 6: - if (!PyArg_ParseTuple(args, "iiiiii:noutrefresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.noutrefresh requires 0 to 6 arguments"); - goto exit; - } - return_value = _curses_window_noutrefresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); - -exit: - return return_value; -} - -#endif /* defined(py_is_pad) */ - -#if !defined(py_is_pad) - -PyDoc_STRVAR(_curses_window_noutrefresh__doc__, -"noutrefresh($self, /)\n" -"--\n" -"\n" -"Mark for refresh but wait.\n" -"\n" -"This function updates the data structure representing the desired state of the\n" -"window, but does not force an update of the physical screen. To accomplish\n" -"that, call doupdate()."); - -#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ - {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_NOARGS, _curses_window_noutrefresh__doc__}, - -static PyObject * -_curses_window_noutrefresh_impl(PyCursesWindowObject *self); - -static PyObject * -_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_window_noutrefresh_impl(self); -} - -#endif /* !defined(py_is_pad) */ - -PyDoc_STRVAR(_curses_window_overlay__doc__, -"overlay(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])\n" -"Overlay the window on top of destwin.\n" -"\n" -"The windows need not be the same size, only the overlapping region is copied.\n" -"This copy is non-destructive, which means that the current background\n" -"character does not overwrite the old contents of destwin.\n" -"\n" -"To get fine-grained control over the copied region, the second form of\n" -"overlay() can be used. sminrow and smincol are the upper-left coordinates\n" -"of the source window, and the other variables mark a rectangle in the\n" -"destination window."); - -#define _CURSES_WINDOW_OVERLAY_METHODDEF \ - {"overlay", (PyCFunction)_curses_window_overlay, METH_VARARGS, _curses_window_overlay__doc__}, - -static PyObject * -_curses_window_overlay_impl(PyCursesWindowObject *self, - PyCursesWindowObject *destwin, int group_right_1, - int sminrow, int smincol, int dminrow, - int dmincol, int dmaxrow, int dmaxcol); - -static PyObject * -_curses_window_overlay(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *destwin; - int group_right_1 = 0; - int sminrow = 0; - int smincol = 0; - int dminrow = 0; - int dmincol = 0; - int dmaxrow = 0; - int dmaxcol = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!:overlay", &PyCursesWindow_Type, &destwin)) { - goto exit; - } - break; - case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.overlay requires 1 to 7 arguments"); - goto exit; - } - return_value = _curses_window_overlay_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_overwrite__doc__, -"overwrite(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow,\n" -" dmaxcol])\n" -"Overwrite the window on top of destwin.\n" -"\n" -"The windows need not be the same size, in which case only the overlapping\n" -"region is copied. This copy is destructive, which means that the current\n" -"background character overwrites the old contents of destwin.\n" -"\n" -"To get fine-grained control over the copied region, the second form of\n" -"overwrite() can be used. sminrow and smincol are the upper-left coordinates\n" -"of the source window, the other variables mark a rectangle in the destination\n" -"window."); - -#define _CURSES_WINDOW_OVERWRITE_METHODDEF \ - {"overwrite", (PyCFunction)_curses_window_overwrite, METH_VARARGS, _curses_window_overwrite__doc__}, - -static PyObject * -_curses_window_overwrite_impl(PyCursesWindowObject *self, - PyCursesWindowObject *destwin, - int group_right_1, int sminrow, int smincol, - int dminrow, int dmincol, int dmaxrow, - int dmaxcol); - -static PyObject * -_curses_window_overwrite(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *destwin; - int group_right_1 = 0; - int sminrow = 0; - int smincol = 0; - int dminrow = 0; - int dmincol = 0; - int dmaxrow = 0; - int dmaxcol = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!:overwrite", &PyCursesWindow_Type, &destwin)) { - goto exit; - } - break; - case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.overwrite requires 1 to 7 arguments"); - goto exit; - } - return_value = _curses_window_overwrite_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_putwin__doc__, -"putwin($self, file, /)\n" -"--\n" -"\n" -"Write all data associated with the window into the provided file object.\n" -"\n" -"This information can be later retrieved using the getwin() function."); - -#define _CURSES_WINDOW_PUTWIN_METHODDEF \ - {"putwin", (PyCFunction)_curses_window_putwin, METH_O, _curses_window_putwin__doc__}, - -PyDoc_STRVAR(_curses_window_redrawln__doc__, -"redrawln($self, beg, num, /)\n" -"--\n" -"\n" -"Mark the specified lines corrupted.\n" -"\n" -" beg\n" -" Starting line number.\n" -" num\n" -" The number of lines.\n" -"\n" -"They should be completely redrawn on the next refresh() call."); - -#define _CURSES_WINDOW_REDRAWLN_METHODDEF \ - {"redrawln", (PyCFunction)(void(*)(void))_curses_window_redrawln, METH_FASTCALL, _curses_window_redrawln__doc__}, - -static PyObject * -_curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num); - -static PyObject * -_curses_window_redrawln(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int beg; - int num; - - if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - beg = _PyLong_AsInt(args[0]); - if (beg == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - num = _PyLong_AsInt(args[1]); - if (num == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_redrawln_impl(self, beg, num); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_refresh__doc__, -"refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" -"Update the display immediately.\n" -"\n" -"Synchronize actual screen with previous drawing/deleting methods.\n" -"The 6 optional arguments can only be specified when the window is a pad\n" -"created with newpad(). The additional parameters are needed to indicate\n" -"what part of the pad and screen are involved. pminrow and pmincol specify\n" -"the upper left-hand corner of the rectangle to be displayed in the pad.\n" -"sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to\n" -"be displayed on the screen. The lower right-hand corner of the rectangle to\n" -"be displayed in the pad is calculated from the screen coordinates, since the\n" -"rectangles must be the same size. Both rectangles must be entirely contained\n" -"within their respective structures. Negative values of pminrow, pmincol,\n" -"sminrow, or smincol are treated as if they were zero."); - -#define _CURSES_WINDOW_REFRESH_METHODDEF \ - {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__}, - -static PyObject * -_curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, - int pminrow, int pmincol, int sminrow, - int smincol, int smaxrow, int smaxcol); - -static PyObject * -_curses_window_refresh(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int pminrow = 0; - int pmincol = 0; - int sminrow = 0; - int smincol = 0; - int smaxrow = 0; - int smaxcol = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 6: - if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments"); - goto exit; - } - return_value = _curses_window_refresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_setscrreg__doc__, -"setscrreg($self, top, bottom, /)\n" -"--\n" -"\n" -"Define a software scrolling region.\n" -"\n" -" top\n" -" First line number.\n" -" bottom\n" -" Last line number.\n" -"\n" -"All scrolling actions will take place in this region."); - -#define _CURSES_WINDOW_SETSCRREG_METHODDEF \ - {"setscrreg", (PyCFunction)(void(*)(void))_curses_window_setscrreg, METH_FASTCALL, _curses_window_setscrreg__doc__}, - -static PyObject * -_curses_window_setscrreg_impl(PyCursesWindowObject *self, int top, - int bottom); - -static PyObject * -_curses_window_setscrreg(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int top; - int bottom; - - if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - top = _PyLong_AsInt(args[0]); - if (top == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bottom = _PyLong_AsInt(args[1]); - if (bottom == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_window_setscrreg_impl(self, top, bottom); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_subwin__doc__, -"subwin([nlines=0, ncols=0,] begin_y, begin_x)\n" -"Create a sub-window (screen-relative coordinates).\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width.\n" -" begin_y\n" -" Top side y-coordinate.\n" -" begin_x\n" -" Left side x-coordinate.\n" -"\n" -"By default, the sub-window will extend from the specified position to the\n" -"lower right corner of the window."); - -#define _CURSES_WINDOW_SUBWIN_METHODDEF \ - {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, - -static PyObject * -_curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1, - int nlines, int ncols, int begin_y, int begin_x); - -static PyObject * -_curses_window_subwin(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int nlines = 0; - int ncols = 0; - int begin_y; - int begin_x; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) { - goto exit; - } - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments"); - goto exit; - } - return_value = _curses_window_subwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_scroll__doc__, -"scroll([lines=1])\n" -"Scroll the screen or scrolling region.\n" -"\n" -" lines\n" -" Number of lines to scroll.\n" -"\n" -"Scroll upward if the argument is positive and downward if it is negative."); - -#define _CURSES_WINDOW_SCROLL_METHODDEF \ - {"scroll", (PyCFunction)_curses_window_scroll, METH_VARARGS, _curses_window_scroll__doc__}, - -static PyObject * -_curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1, - int lines); - -static PyObject * -_curses_window_scroll(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_right_1 = 0; - int lines = 1; - - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 1: - if (!PyArg_ParseTuple(args, "i:scroll", &lines)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments"); - goto exit; - } - return_value = _curses_window_scroll_impl(self, group_right_1, lines); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_touchline__doc__, -"touchline(start, count, [changed=True])\n" -"Pretend count lines have been changed, starting with line start.\n" -"\n" -"If changed is supplied, it specifies whether the affected lines are marked\n" -"as having been changed (changed=True) or unchanged (changed=False)."); - -#define _CURSES_WINDOW_TOUCHLINE_METHODDEF \ - {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__}, - -static PyObject * -_curses_window_touchline_impl(PyCursesWindowObject *self, int start, - int count, int group_right_1, int changed); - -static PyObject * -_curses_window_touchline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int start; - int count; - int group_right_1 = 0; - int changed = 1; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "iii:touchline", &start, &count, &changed)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments"); - goto exit; - } - return_value = _curses_window_touchline_impl(self, start, count, group_right_1, changed); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_window_vline__doc__, -"vline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n" -"Display a vertical line.\n" -"\n" -" y\n" -" Starting Y-coordinate.\n" -" x\n" -" Starting X-coordinate.\n" -" ch\n" -" Character to draw.\n" -" n\n" -" Line length.\n" -" attr\n" -" Attributes for the character."); - -#define _CURSES_WINDOW_VLINE_METHODDEF \ - {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__}, - -static PyObject * -_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, - int y, int x, PyObject *ch, int n, - int group_right_1, long attr); - -static PyObject * -_curses_window_vline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *ch; - int n; - int group_right_1 = 0; - long attr = A_NORMAL; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:vline", &ch, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:vline", &y, &x, &ch, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments"); - goto exit; - } - return_value = _curses_window_vline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr); - -exit: - return return_value; -} - -#if defined(HAVE_CURSES_FILTER) - -PyDoc_STRVAR(_curses_filter__doc__, -"filter($module, /)\n" -"--\n" -"\n"); - -#define _CURSES_FILTER_METHODDEF \ - {"filter", (PyCFunction)_curses_filter, METH_NOARGS, _curses_filter__doc__}, - -static PyObject * -_curses_filter_impl(PyObject *module); - -static PyObject * -_curses_filter(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_filter_impl(module); -} - -#endif /* defined(HAVE_CURSES_FILTER) */ - -PyDoc_STRVAR(_curses_baudrate__doc__, -"baudrate($module, /)\n" -"--\n" -"\n" -"Return the output speed of the terminal in bits per second."); - -#define _CURSES_BAUDRATE_METHODDEF \ - {"baudrate", (PyCFunction)_curses_baudrate, METH_NOARGS, _curses_baudrate__doc__}, - -static PyObject * -_curses_baudrate_impl(PyObject *module); - -static PyObject * -_curses_baudrate(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_baudrate_impl(module); -} - -PyDoc_STRVAR(_curses_beep__doc__, -"beep($module, /)\n" -"--\n" -"\n" -"Emit a short attention sound."); - -#define _CURSES_BEEP_METHODDEF \ - {"beep", (PyCFunction)_curses_beep, METH_NOARGS, _curses_beep__doc__}, - -static PyObject * -_curses_beep_impl(PyObject *module); - -static PyObject * -_curses_beep(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_beep_impl(module); -} - -PyDoc_STRVAR(_curses_can_change_color__doc__, -"can_change_color($module, /)\n" -"--\n" -"\n" -"Return True if the programmer can change the colors displayed by the terminal."); - -#define _CURSES_CAN_CHANGE_COLOR_METHODDEF \ - {"can_change_color", (PyCFunction)_curses_can_change_color, METH_NOARGS, _curses_can_change_color__doc__}, - -static PyObject * -_curses_can_change_color_impl(PyObject *module); - -static PyObject * -_curses_can_change_color(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_can_change_color_impl(module); -} - -PyDoc_STRVAR(_curses_cbreak__doc__, -"cbreak($module, flag=True, /)\n" -"--\n" -"\n" -"Enter cbreak mode.\n" -"\n" -" flag\n" -" If false, the effect is the same as calling nocbreak().\n" -"\n" -"In cbreak mode (sometimes called \"rare\" mode) normal tty line buffering is\n" -"turned off and characters are available to be read one by one. However,\n" -"unlike raw mode, special characters (interrupt, quit, suspend, and flow\n" -"control) retain their effects on the tty driver and calling program.\n" -"Calling first raw() then cbreak() leaves the terminal in cbreak mode."); - -#define _CURSES_CBREAK_METHODDEF \ - {"cbreak", (PyCFunction)(void(*)(void))_curses_cbreak, METH_FASTCALL, _curses_cbreak__doc__}, - -static PyObject * -_curses_cbreak_impl(PyObject *module, int flag); - -static PyObject * -_curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[0]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_cbreak_impl(module, flag); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_color_content__doc__, -"color_content($module, color_number, /)\n" -"--\n" -"\n" -"Return the red, green, and blue (RGB) components of the specified color.\n" -"\n" -" color_number\n" -" The number of the color (0 - (COLORS-1)).\n" -"\n" -"A 3-tuple is returned, containing the R, G, B values for the given color,\n" -"which will be between 0 (no component) and 1000 (maximum amount of component)."); - -#define _CURSES_COLOR_CONTENT_METHODDEF \ - {"color_content", (PyCFunction)_curses_color_content, METH_O, _curses_color_content__doc__}, - -static PyObject * -_curses_color_content_impl(PyObject *module, short color_number); - -static PyObject * -_curses_color_content(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - short color_number; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - color_number = (short) ival; - } - } - return_value = _curses_color_content_impl(module, color_number); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_color_pair__doc__, -"color_pair($module, pair_number, /)\n" -"--\n" -"\n" -"Return the attribute value for displaying text in the specified color.\n" -"\n" -" pair_number\n" -" The number of the color pair.\n" -"\n" -"This attribute value can be combined with A_STANDOUT, A_REVERSE, and the\n" -"other A_* attributes. pair_number() is the counterpart to this function."); - -#define _CURSES_COLOR_PAIR_METHODDEF \ - {"color_pair", (PyCFunction)_curses_color_pair, METH_O, _curses_color_pair__doc__}, - -static PyObject * -_curses_color_pair_impl(PyObject *module, short pair_number); - -static PyObject * -_curses_color_pair(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - short pair_number; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - pair_number = (short) ival; - } - } - return_value = _curses_color_pair_impl(module, pair_number); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_curs_set__doc__, -"curs_set($module, visibility, /)\n" -"--\n" -"\n" -"Set the cursor state.\n" -"\n" -" visibility\n" -" 0 for invisible, 1 for normal visible, or 2 for very visible.\n" -"\n" -"If the terminal supports the visibility requested, the previous cursor\n" -"state is returned; otherwise, an exception is raised. On many terminals,\n" -"the \"visible\" mode is an underline cursor and the \"very visible\" mode is\n" -"a block cursor."); - -#define _CURSES_CURS_SET_METHODDEF \ - {"curs_set", (PyCFunction)_curses_curs_set, METH_O, _curses_curs_set__doc__}, - -static PyObject * -_curses_curs_set_impl(PyObject *module, int visibility); - -static PyObject * -_curses_curs_set(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int visibility; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - visibility = _PyLong_AsInt(arg); - if (visibility == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_curs_set_impl(module, visibility); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_def_prog_mode__doc__, -"def_prog_mode($module, /)\n" -"--\n" -"\n" -"Save the current terminal mode as the \"program\" mode.\n" -"\n" -"The \"program\" mode is the mode when the running program is using curses.\n" -"\n" -"Subsequent calls to reset_prog_mode() will restore this mode."); - -#define _CURSES_DEF_PROG_MODE_METHODDEF \ - {"def_prog_mode", (PyCFunction)_curses_def_prog_mode, METH_NOARGS, _curses_def_prog_mode__doc__}, - -static PyObject * -_curses_def_prog_mode_impl(PyObject *module); - -static PyObject * -_curses_def_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_def_prog_mode_impl(module); -} - -PyDoc_STRVAR(_curses_def_shell_mode__doc__, -"def_shell_mode($module, /)\n" -"--\n" -"\n" -"Save the current terminal mode as the \"shell\" mode.\n" -"\n" -"The \"shell\" mode is the mode when the running program is not using curses.\n" -"\n" -"Subsequent calls to reset_shell_mode() will restore this mode."); - -#define _CURSES_DEF_SHELL_MODE_METHODDEF \ - {"def_shell_mode", (PyCFunction)_curses_def_shell_mode, METH_NOARGS, _curses_def_shell_mode__doc__}, - -static PyObject * -_curses_def_shell_mode_impl(PyObject *module); - -static PyObject * -_curses_def_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_def_shell_mode_impl(module); -} - -PyDoc_STRVAR(_curses_delay_output__doc__, -"delay_output($module, ms, /)\n" -"--\n" -"\n" -"Insert a pause in output.\n" -"\n" -" ms\n" -" Duration in milliseconds."); - -#define _CURSES_DELAY_OUTPUT_METHODDEF \ - {"delay_output", (PyCFunction)_curses_delay_output, METH_O, _curses_delay_output__doc__}, - -static PyObject * -_curses_delay_output_impl(PyObject *module, int ms); - -static PyObject * -_curses_delay_output(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int ms; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ms = _PyLong_AsInt(arg); - if (ms == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_delay_output_impl(module, ms); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_doupdate__doc__, -"doupdate($module, /)\n" -"--\n" -"\n" -"Update the physical screen to match the virtual screen."); - -#define _CURSES_DOUPDATE_METHODDEF \ - {"doupdate", (PyCFunction)_curses_doupdate, METH_NOARGS, _curses_doupdate__doc__}, - -static PyObject * -_curses_doupdate_impl(PyObject *module); - -static PyObject * -_curses_doupdate(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_doupdate_impl(module); -} - -PyDoc_STRVAR(_curses_echo__doc__, -"echo($module, flag=True, /)\n" -"--\n" -"\n" -"Enter echo mode.\n" -"\n" -" flag\n" -" If false, the effect is the same as calling noecho().\n" -"\n" -"In echo mode, each character input is echoed to the screen as it is entered."); - -#define _CURSES_ECHO_METHODDEF \ - {"echo", (PyCFunction)(void(*)(void))_curses_echo, METH_FASTCALL, _curses_echo__doc__}, - -static PyObject * -_curses_echo_impl(PyObject *module, int flag); - -static PyObject * -_curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[0]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_echo_impl(module, flag); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_endwin__doc__, -"endwin($module, /)\n" -"--\n" -"\n" -"De-initialize the library, and return terminal to normal status."); - -#define _CURSES_ENDWIN_METHODDEF \ - {"endwin", (PyCFunction)_curses_endwin, METH_NOARGS, _curses_endwin__doc__}, - -static PyObject * -_curses_endwin_impl(PyObject *module); - -static PyObject * -_curses_endwin(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_endwin_impl(module); -} - -PyDoc_STRVAR(_curses_erasechar__doc__, -"erasechar($module, /)\n" -"--\n" -"\n" -"Return the user\'s current erase character."); - -#define _CURSES_ERASECHAR_METHODDEF \ - {"erasechar", (PyCFunction)_curses_erasechar, METH_NOARGS, _curses_erasechar__doc__}, - -static PyObject * -_curses_erasechar_impl(PyObject *module); - -static PyObject * -_curses_erasechar(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_erasechar_impl(module); -} - -PyDoc_STRVAR(_curses_flash__doc__, -"flash($module, /)\n" -"--\n" -"\n" -"Flash the screen.\n" -"\n" -"That is, change it to reverse-video and then change it back in a short interval."); - -#define _CURSES_FLASH_METHODDEF \ - {"flash", (PyCFunction)_curses_flash, METH_NOARGS, _curses_flash__doc__}, - -static PyObject * -_curses_flash_impl(PyObject *module); - -static PyObject * -_curses_flash(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_flash_impl(module); -} - -PyDoc_STRVAR(_curses_flushinp__doc__, -"flushinp($module, /)\n" -"--\n" -"\n" -"Flush all input buffers.\n" -"\n" -"This throws away any typeahead that has been typed by the user and has not\n" -"yet been processed by the program."); - -#define _CURSES_FLUSHINP_METHODDEF \ - {"flushinp", (PyCFunction)_curses_flushinp, METH_NOARGS, _curses_flushinp__doc__}, - -static PyObject * -_curses_flushinp_impl(PyObject *module); - -static PyObject * -_curses_flushinp(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_flushinp_impl(module); -} - -#if defined(getsyx) - -PyDoc_STRVAR(_curses_getsyx__doc__, -"getsyx($module, /)\n" -"--\n" -"\n" -"Return the current coordinates of the virtual screen cursor.\n" -"\n" -"Return a (y, x) tuple. If leaveok is currently true, return (-1, -1)."); - -#define _CURSES_GETSYX_METHODDEF \ - {"getsyx", (PyCFunction)_curses_getsyx, METH_NOARGS, _curses_getsyx__doc__}, - -static PyObject * -_curses_getsyx_impl(PyObject *module); - -static PyObject * -_curses_getsyx(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_getsyx_impl(module); -} - -#endif /* defined(getsyx) */ - -#if defined(NCURSES_MOUSE_VERSION) - -PyDoc_STRVAR(_curses_getmouse__doc__, -"getmouse($module, /)\n" -"--\n" -"\n" -"Retrieve the queued mouse event.\n" -"\n" -"After getch() returns KEY_MOUSE to signal a mouse event, this function\n" -"returns a 5-tuple (id, x, y, z, bstate)."); - -#define _CURSES_GETMOUSE_METHODDEF \ - {"getmouse", (PyCFunction)_curses_getmouse, METH_NOARGS, _curses_getmouse__doc__}, - -static PyObject * -_curses_getmouse_impl(PyObject *module); - -static PyObject * -_curses_getmouse(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_getmouse_impl(module); -} - -#endif /* defined(NCURSES_MOUSE_VERSION) */ - -#if defined(NCURSES_MOUSE_VERSION) - -PyDoc_STRVAR(_curses_ungetmouse__doc__, -"ungetmouse($module, id, x, y, z, bstate, /)\n" -"--\n" -"\n" -"Push a KEY_MOUSE event onto the input queue.\n" -"\n" -"The following getmouse() will return the given state data."); - -#define _CURSES_UNGETMOUSE_METHODDEF \ - {"ungetmouse", (PyCFunction)(void(*)(void))_curses_ungetmouse, METH_FASTCALL, _curses_ungetmouse__doc__}, - -static PyObject * -_curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z, - unsigned long bstate); - -static PyObject * -_curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - short id; - int x; - int y; - int z; - unsigned long bstate; - - if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[0]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - id = (short) ival; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - x = _PyLong_AsInt(args[1]); - if (x == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - y = _PyLong_AsInt(args[2]); - if (y == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - z = _PyLong_AsInt(args[3]); - if (z == -1 && PyErr_Occurred()) { - goto exit; - } - if (!PyLong_Check(args[4])) { - _PyArg_BadArgument("ungetmouse", "argument 5", "int", args[4]); - goto exit; - } - bstate = PyLong_AsUnsignedLongMask(args[4]); - return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate); - -exit: - return return_value; -} - -#endif /* defined(NCURSES_MOUSE_VERSION) */ - -PyDoc_STRVAR(_curses_getwin__doc__, -"getwin($module, file, /)\n" -"--\n" -"\n" -"Read window related data stored in the file by an earlier putwin() call.\n" -"\n" -"The routine then creates and initializes a new window using that data,\n" -"returning the new window object."); - -#define _CURSES_GETWIN_METHODDEF \ - {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__}, - -PyDoc_STRVAR(_curses_halfdelay__doc__, -"halfdelay($module, tenths, /)\n" -"--\n" -"\n" -"Enter half-delay mode.\n" -"\n" -" tenths\n" -" Maximal blocking delay in tenths of seconds (1 - 255).\n" -"\n" -"Use nocbreak() to leave half-delay mode."); - -#define _CURSES_HALFDELAY_METHODDEF \ - {"halfdelay", (PyCFunction)_curses_halfdelay, METH_O, _curses_halfdelay__doc__}, - -static PyObject * -_curses_halfdelay_impl(PyObject *module, unsigned char tenths); - -static PyObject * -_curses_halfdelay(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - unsigned char tenths; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < 0) { - PyErr_SetString(PyExc_OverflowError, - "unsigned byte integer is less than minimum"); - goto exit; - } - else if (ival > UCHAR_MAX) { - PyErr_SetString(PyExc_OverflowError, - "unsigned byte integer is greater than maximum"); - goto exit; - } - else { - tenths = (unsigned char) ival; - } - } - return_value = _curses_halfdelay_impl(module, tenths); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_has_colors__doc__, -"has_colors($module, /)\n" -"--\n" -"\n" -"Return True if the terminal can display colors; otherwise, return False."); - -#define _CURSES_HAS_COLORS_METHODDEF \ - {"has_colors", (PyCFunction)_curses_has_colors, METH_NOARGS, _curses_has_colors__doc__}, - -static PyObject * -_curses_has_colors_impl(PyObject *module); - -static PyObject * -_curses_has_colors(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_has_colors_impl(module); -} - -PyDoc_STRVAR(_curses_has_ic__doc__, -"has_ic($module, /)\n" -"--\n" -"\n" -"Return True if the terminal has insert- and delete-character capabilities."); - -#define _CURSES_HAS_IC_METHODDEF \ - {"has_ic", (PyCFunction)_curses_has_ic, METH_NOARGS, _curses_has_ic__doc__}, - -static PyObject * -_curses_has_ic_impl(PyObject *module); - -static PyObject * -_curses_has_ic(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_has_ic_impl(module); -} - -PyDoc_STRVAR(_curses_has_il__doc__, -"has_il($module, /)\n" -"--\n" -"\n" -"Return True if the terminal has insert- and delete-line capabilities."); - -#define _CURSES_HAS_IL_METHODDEF \ - {"has_il", (PyCFunction)_curses_has_il, METH_NOARGS, _curses_has_il__doc__}, - -static PyObject * -_curses_has_il_impl(PyObject *module); - -static PyObject * -_curses_has_il(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_has_il_impl(module); -} - -#if defined(HAVE_CURSES_HAS_KEY) - -PyDoc_STRVAR(_curses_has_key__doc__, -"has_key($module, key, /)\n" -"--\n" -"\n" -"Return True if the current terminal type recognizes a key with that value.\n" -"\n" -" key\n" -" Key number."); - -#define _CURSES_HAS_KEY_METHODDEF \ - {"has_key", (PyCFunction)_curses_has_key, METH_O, _curses_has_key__doc__}, - -static PyObject * -_curses_has_key_impl(PyObject *module, int key); - -static PyObject * -_curses_has_key(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int key; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - key = _PyLong_AsInt(arg); - if (key == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_has_key_impl(module, key); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_HAS_KEY) */ - -PyDoc_STRVAR(_curses_init_color__doc__, -"init_color($module, color_number, r, g, b, /)\n" -"--\n" -"\n" -"Change the definition of a color.\n" -"\n" -" color_number\n" -" The number of the color to be changed (0 - (COLORS-1)).\n" -" r\n" -" Red component (0 - 1000).\n" -" g\n" -" Green component (0 - 1000).\n" -" b\n" -" Blue component (0 - 1000).\n" -"\n" -"When init_color() is used, all occurrences of that color on the screen\n" -"immediately change to the new definition. This function is a no-op on\n" -"most terminals; it is active only if can_change_color() returns true."); - -#define _CURSES_INIT_COLOR_METHODDEF \ - {"init_color", (PyCFunction)(void(*)(void))_curses_init_color, METH_FASTCALL, _curses_init_color__doc__}, - -static PyObject * -_curses_init_color_impl(PyObject *module, short color_number, short r, - short g, short b); - -static PyObject * -_curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - short color_number; - short r; - short g; - short b; - - if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[0]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - color_number = (short) ival; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[1]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - r = (short) ival; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[2]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - g = (short) ival; - } - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[3]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - b = (short) ival; - } - } - return_value = _curses_init_color_impl(module, color_number, r, g, b); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_init_pair__doc__, -"init_pair($module, pair_number, fg, bg, /)\n" -"--\n" -"\n" -"Change the definition of a color-pair.\n" -"\n" -" pair_number\n" -" The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).\n" -" fg\n" -" Foreground color number (-1 - (COLORS-1)).\n" -" bg\n" -" Background color number (-1 - (COLORS-1)).\n" -"\n" -"If the color-pair was previously initialized, the screen is refreshed and\n" -"all occurrences of that color-pair are changed to the new definition."); - -#define _CURSES_INIT_PAIR_METHODDEF \ - {"init_pair", (PyCFunction)(void(*)(void))_curses_init_pair, METH_FASTCALL, _curses_init_pair__doc__}, - -static PyObject * -_curses_init_pair_impl(PyObject *module, short pair_number, short fg, - short bg); - -static PyObject * -_curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - short pair_number; - short fg; - short bg; - - if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[0]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - pair_number = (short) ival; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[1]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - fg = (short) ival; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(args[2]); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - bg = (short) ival; - } - } - return_value = _curses_init_pair_impl(module, pair_number, fg, bg); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_initscr__doc__, -"initscr($module, /)\n" -"--\n" -"\n" -"Initialize the library.\n" -"\n" -"Return a WindowObject which represents the whole screen."); - -#define _CURSES_INITSCR_METHODDEF \ - {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__}, - -static PyObject * -_curses_initscr_impl(PyObject *module); - -static PyObject * -_curses_initscr(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_initscr_impl(module); -} - -PyDoc_STRVAR(_curses_setupterm__doc__, -"setupterm($module, /, term=None, fd=-1)\n" -"--\n" -"\n" -"Initialize the terminal.\n" -"\n" -" term\n" -" Terminal name.\n" -" If omitted, the value of the TERM environment variable will be used.\n" -" fd\n" -" File descriptor to which any initialization sequences will be sent.\n" -" If not supplied, the file descriptor for sys.stdout will be used."); - -#define _CURSES_SETUPTERM_METHODDEF \ - {"setupterm", (PyCFunction)(void(*)(void))_curses_setupterm, METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__}, - -static PyObject * -_curses_setupterm_impl(PyObject *module, const char *term, int fd); - -static PyObject * -_curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"term", "fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "setupterm", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - const char *term = NULL; - int fd = -1; - - 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]) { - if (args[0] == Py_None) { - term = NULL; - } - else if (PyUnicode_Check(args[0])) { - Py_ssize_t term_length; - term = PyUnicode_AsUTF8AndSize(args[0], &term_length); - if (term == NULL) { - goto exit; - } - if (strlen(term) != (size_t)term_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("setupterm", "argument 'term'", "str or None", args[0]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[1]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = _curses_setupterm_impl(module, term, fd); - -exit: - return return_value; -} - -#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) - -PyDoc_STRVAR(_curses_get_escdelay__doc__, -"get_escdelay($module, /)\n" -"--\n" -"\n" -"Gets the curses ESCDELAY setting.\n" -"\n" -"Gets the number of milliseconds to wait after reading an escape character,\n" -"to distinguish between an individual escape character entered on the\n" -"keyboard from escape sequences sent by cursor and function keys."); - -#define _CURSES_GET_ESCDELAY_METHODDEF \ - {"get_escdelay", (PyCFunction)_curses_get_escdelay, METH_NOARGS, _curses_get_escdelay__doc__}, - -static PyObject * -_curses_get_escdelay_impl(PyObject *module); - -static PyObject * -_curses_get_escdelay(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_get_escdelay_impl(module); -} - -#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ - -#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) - -PyDoc_STRVAR(_curses_set_escdelay__doc__, -"set_escdelay($module, ms, /)\n" -"--\n" -"\n" -"Sets the curses ESCDELAY setting.\n" -"\n" -" ms\n" -" length of the delay in milliseconds.\n" -"\n" -"Sets the number of milliseconds to wait after reading an escape character,\n" -"to distinguish between an individual escape character entered on the\n" -"keyboard from escape sequences sent by cursor and function keys."); - -#define _CURSES_SET_ESCDELAY_METHODDEF \ - {"set_escdelay", (PyCFunction)_curses_set_escdelay, METH_O, _curses_set_escdelay__doc__}, - -static PyObject * -_curses_set_escdelay_impl(PyObject *module, int ms); - -static PyObject * -_curses_set_escdelay(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int ms; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ms = _PyLong_AsInt(arg); - if (ms == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_set_escdelay_impl(module, ms); - -exit: - return return_value; -} - -#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ - -#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) - -PyDoc_STRVAR(_curses_get_tabsize__doc__, -"get_tabsize($module, /)\n" -"--\n" -"\n" -"Gets the curses TABSIZE setting.\n" -"\n" -"Gets the number of columns used by the curses library when converting a tab\n" -"character to spaces as it adds the tab to a window."); - -#define _CURSES_GET_TABSIZE_METHODDEF \ - {"get_tabsize", (PyCFunction)_curses_get_tabsize, METH_NOARGS, _curses_get_tabsize__doc__}, - -static PyObject * -_curses_get_tabsize_impl(PyObject *module); - -static PyObject * -_curses_get_tabsize(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_get_tabsize_impl(module); -} - -#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ - -#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) - -PyDoc_STRVAR(_curses_set_tabsize__doc__, -"set_tabsize($module, size, /)\n" -"--\n" -"\n" -"Sets the curses TABSIZE setting.\n" -"\n" -" size\n" -" rendered cell width of a tab character.\n" -"\n" -"Sets the number of columns used by the curses library when converting a tab\n" -"character to spaces as it adds the tab to a window."); - -#define _CURSES_SET_TABSIZE_METHODDEF \ - {"set_tabsize", (PyCFunction)_curses_set_tabsize, METH_O, _curses_set_tabsize__doc__}, - -static PyObject * -_curses_set_tabsize_impl(PyObject *module, int size); - -static PyObject * -_curses_set_tabsize(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int size; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - size = _PyLong_AsInt(arg); - if (size == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_set_tabsize_impl(module, size); - -exit: - return return_value; -} - -#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ - -PyDoc_STRVAR(_curses_intrflush__doc__, -"intrflush($module, flag, /)\n" -"--\n" -"\n"); - -#define _CURSES_INTRFLUSH_METHODDEF \ - {"intrflush", (PyCFunction)_curses_intrflush, METH_O, _curses_intrflush__doc__}, - -static PyObject * -_curses_intrflush_impl(PyObject *module, int flag); - -static PyObject * -_curses_intrflush(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int flag; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(arg); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_intrflush_impl(module, flag); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_isendwin__doc__, -"isendwin($module, /)\n" -"--\n" -"\n" -"Return True if endwin() has been called."); - -#define _CURSES_ISENDWIN_METHODDEF \ - {"isendwin", (PyCFunction)_curses_isendwin, METH_NOARGS, _curses_isendwin__doc__}, - -static PyObject * -_curses_isendwin_impl(PyObject *module); - -static PyObject * -_curses_isendwin(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_isendwin_impl(module); -} - -#if defined(HAVE_CURSES_IS_TERM_RESIZED) - -PyDoc_STRVAR(_curses_is_term_resized__doc__, -"is_term_resized($module, nlines, ncols, /)\n" -"--\n" -"\n" -"Return True if resize_term() would modify the window structure, False otherwise.\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width."); - -#define _CURSES_IS_TERM_RESIZED_METHODDEF \ - {"is_term_resized", (PyCFunction)(void(*)(void))_curses_is_term_resized, METH_FASTCALL, _curses_is_term_resized__doc__}, - -static PyObject * -_curses_is_term_resized_impl(PyObject *module, int nlines, int ncols); - -static PyObject * -_curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int nlines; - int ncols; - - if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nlines = _PyLong_AsInt(args[0]); - if (nlines == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ncols = _PyLong_AsInt(args[1]); - if (ncols == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_is_term_resized_impl(module, nlines, ncols); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_IS_TERM_RESIZED) */ - -PyDoc_STRVAR(_curses_keyname__doc__, -"keyname($module, key, /)\n" -"--\n" -"\n" -"Return the name of specified key.\n" -"\n" -" key\n" -" Key number."); - -#define _CURSES_KEYNAME_METHODDEF \ - {"keyname", (PyCFunction)_curses_keyname, METH_O, _curses_keyname__doc__}, - -static PyObject * -_curses_keyname_impl(PyObject *module, int key); - -static PyObject * -_curses_keyname(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int key; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - key = _PyLong_AsInt(arg); - if (key == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_keyname_impl(module, key); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_killchar__doc__, -"killchar($module, /)\n" -"--\n" -"\n" -"Return the user\'s current line kill character."); - -#define _CURSES_KILLCHAR_METHODDEF \ - {"killchar", (PyCFunction)_curses_killchar, METH_NOARGS, _curses_killchar__doc__}, - -static PyObject * -_curses_killchar_impl(PyObject *module); - -static PyObject * -_curses_killchar(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_killchar_impl(module); -} - -PyDoc_STRVAR(_curses_longname__doc__, -"longname($module, /)\n" -"--\n" -"\n" -"Return the terminfo long name field describing the current terminal.\n" -"\n" -"The maximum length of a verbose description is 128 characters. It is defined\n" -"only after the call to initscr()."); - -#define _CURSES_LONGNAME_METHODDEF \ - {"longname", (PyCFunction)_curses_longname, METH_NOARGS, _curses_longname__doc__}, - -static PyObject * -_curses_longname_impl(PyObject *module); - -static PyObject * -_curses_longname(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_longname_impl(module); -} - -PyDoc_STRVAR(_curses_meta__doc__, -"meta($module, yes, /)\n" -"--\n" -"\n" -"Enable/disable meta keys.\n" -"\n" -"If yes is True, allow 8-bit characters to be input. If yes is False,\n" -"allow only 7-bit characters."); - -#define _CURSES_META_METHODDEF \ - {"meta", (PyCFunction)_curses_meta, METH_O, _curses_meta__doc__}, - -static PyObject * -_curses_meta_impl(PyObject *module, int yes); - -static PyObject * -_curses_meta(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int yes; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - yes = _PyLong_AsInt(arg); - if (yes == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_meta_impl(module, yes); - -exit: - return return_value; -} - -#if defined(NCURSES_MOUSE_VERSION) - -PyDoc_STRVAR(_curses_mouseinterval__doc__, -"mouseinterval($module, interval, /)\n" -"--\n" -"\n" -"Set and retrieve the maximum time between press and release in a click.\n" -"\n" -" interval\n" -" Time in milliseconds.\n" -"\n" -"Set the maximum time that can elapse between press and release events in\n" -"order for them to be recognized as a click, and return the previous interval\n" -"value."); - -#define _CURSES_MOUSEINTERVAL_METHODDEF \ - {"mouseinterval", (PyCFunction)_curses_mouseinterval, METH_O, _curses_mouseinterval__doc__}, - -static PyObject * -_curses_mouseinterval_impl(PyObject *module, int interval); - -static PyObject * -_curses_mouseinterval(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int interval; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - interval = _PyLong_AsInt(arg); - if (interval == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_mouseinterval_impl(module, interval); - -exit: - return return_value; -} - -#endif /* defined(NCURSES_MOUSE_VERSION) */ - -#if defined(NCURSES_MOUSE_VERSION) - -PyDoc_STRVAR(_curses_mousemask__doc__, -"mousemask($module, newmask, /)\n" -"--\n" -"\n" -"Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n" -"\n" -"Return a tuple (availmask, oldmask). availmask indicates which of the\n" -"specified mouse events can be reported; on complete failure it returns 0.\n" -"oldmask is the previous value of the given window\'s mouse event mask.\n" -"If this function is never called, no mouse events are ever reported."); - -#define _CURSES_MOUSEMASK_METHODDEF \ - {"mousemask", (PyCFunction)_curses_mousemask, METH_O, _curses_mousemask__doc__}, - -static PyObject * -_curses_mousemask_impl(PyObject *module, unsigned long newmask); - -static PyObject * -_curses_mousemask(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - unsigned long newmask; - - if (!PyLong_Check(arg)) { - _PyArg_BadArgument("mousemask", "argument", "int", arg); - goto exit; - } - newmask = PyLong_AsUnsignedLongMask(arg); - return_value = _curses_mousemask_impl(module, newmask); - -exit: - return return_value; -} - -#endif /* defined(NCURSES_MOUSE_VERSION) */ - -PyDoc_STRVAR(_curses_napms__doc__, -"napms($module, ms, /)\n" -"--\n" -"\n" -"Sleep for specified time.\n" -"\n" -" ms\n" -" Duration in milliseconds."); - -#define _CURSES_NAPMS_METHODDEF \ - {"napms", (PyCFunction)_curses_napms, METH_O, _curses_napms__doc__}, - -static PyObject * -_curses_napms_impl(PyObject *module, int ms); - -static PyObject * -_curses_napms(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int ms; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ms = _PyLong_AsInt(arg); - if (ms == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_napms_impl(module, ms); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_newpad__doc__, -"newpad($module, nlines, ncols, /)\n" -"--\n" -"\n" -"Create and return a pointer to a new pad data structure.\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width."); - -#define _CURSES_NEWPAD_METHODDEF \ - {"newpad", (PyCFunction)(void(*)(void))_curses_newpad, METH_FASTCALL, _curses_newpad__doc__}, - -static PyObject * -_curses_newpad_impl(PyObject *module, int nlines, int ncols); - -static PyObject * -_curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int nlines; - int ncols; - - if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nlines = _PyLong_AsInt(args[0]); - if (nlines == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ncols = _PyLong_AsInt(args[1]); - if (ncols == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_newpad_impl(module, nlines, ncols); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_newwin__doc__, -"newwin(nlines, ncols, [begin_y=0, begin_x=0])\n" -"Return a new window.\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width.\n" -" begin_y\n" -" Top side y-coordinate.\n" -" begin_x\n" -" Left side x-coordinate.\n" -"\n" -"By default, the window will extend from the specified position to the lower\n" -"right corner of the screen."); - -#define _CURSES_NEWWIN_METHODDEF \ - {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__}, - -static PyObject * -_curses_newwin_impl(PyObject *module, int nlines, int ncols, - int group_right_1, int begin_y, int begin_x); - -static PyObject * -_curses_newwin(PyObject *module, PyObject *args) -{ - PyObject *return_value = NULL; - int nlines; - int ncols; - int group_right_1 = 0; - int begin_y = 0; - int begin_x = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) { - goto exit; - } - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments"); - goto exit; - } - return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_nl__doc__, -"nl($module, flag=True, /)\n" -"--\n" -"\n" -"Enter newline mode.\n" -"\n" -" flag\n" -" If false, the effect is the same as calling nonl().\n" -"\n" -"This mode translates the return key into newline on input, and translates\n" -"newline into return and line-feed on output. Newline mode is initially on."); - -#define _CURSES_NL_METHODDEF \ - {"nl", (PyCFunction)(void(*)(void))_curses_nl, METH_FASTCALL, _curses_nl__doc__}, - -static PyObject * -_curses_nl_impl(PyObject *module, int flag); - -static PyObject * -_curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[0]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_nl_impl(module, flag); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_nocbreak__doc__, -"nocbreak($module, /)\n" -"--\n" -"\n" -"Leave cbreak mode.\n" -"\n" -"Return to normal \"cooked\" mode with line buffering."); - -#define _CURSES_NOCBREAK_METHODDEF \ - {"nocbreak", (PyCFunction)_curses_nocbreak, METH_NOARGS, _curses_nocbreak__doc__}, - -static PyObject * -_curses_nocbreak_impl(PyObject *module); - -static PyObject * -_curses_nocbreak(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_nocbreak_impl(module); -} - -PyDoc_STRVAR(_curses_noecho__doc__, -"noecho($module, /)\n" -"--\n" -"\n" -"Leave echo mode.\n" -"\n" -"Echoing of input characters is turned off."); - -#define _CURSES_NOECHO_METHODDEF \ - {"noecho", (PyCFunction)_curses_noecho, METH_NOARGS, _curses_noecho__doc__}, - -static PyObject * -_curses_noecho_impl(PyObject *module); - -static PyObject * -_curses_noecho(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_noecho_impl(module); -} - -PyDoc_STRVAR(_curses_nonl__doc__, -"nonl($module, /)\n" -"--\n" -"\n" -"Leave newline mode.\n" -"\n" -"Disable translation of return into newline on input, and disable low-level\n" -"translation of newline into newline/return on output."); - -#define _CURSES_NONL_METHODDEF \ - {"nonl", (PyCFunction)_curses_nonl, METH_NOARGS, _curses_nonl__doc__}, - -static PyObject * -_curses_nonl_impl(PyObject *module); - -static PyObject * -_curses_nonl(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_nonl_impl(module); -} - -PyDoc_STRVAR(_curses_noqiflush__doc__, -"noqiflush($module, /)\n" -"--\n" -"\n" -"Disable queue flushing.\n" -"\n" -"When queue flushing is disabled, normal flush of input and output queues\n" -"associated with the INTR, QUIT and SUSP characters will not be done."); - -#define _CURSES_NOQIFLUSH_METHODDEF \ - {"noqiflush", (PyCFunction)_curses_noqiflush, METH_NOARGS, _curses_noqiflush__doc__}, - -static PyObject * -_curses_noqiflush_impl(PyObject *module); - -static PyObject * -_curses_noqiflush(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_noqiflush_impl(module); -} - -PyDoc_STRVAR(_curses_noraw__doc__, -"noraw($module, /)\n" -"--\n" -"\n" -"Leave raw mode.\n" -"\n" -"Return to normal \"cooked\" mode with line buffering."); - -#define _CURSES_NORAW_METHODDEF \ - {"noraw", (PyCFunction)_curses_noraw, METH_NOARGS, _curses_noraw__doc__}, - -static PyObject * -_curses_noraw_impl(PyObject *module); - -static PyObject * -_curses_noraw(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_noraw_impl(module); -} - -PyDoc_STRVAR(_curses_pair_content__doc__, -"pair_content($module, pair_number, /)\n" -"--\n" -"\n" -"Return a tuple (fg, bg) containing the colors for the requested color pair.\n" -"\n" -" pair_number\n" -" The number of the color pair (1 - (COLOR_PAIRS-1))."); - -#define _CURSES_PAIR_CONTENT_METHODDEF \ - {"pair_content", (PyCFunction)_curses_pair_content, METH_O, _curses_pair_content__doc__}, - -static PyObject * -_curses_pair_content_impl(PyObject *module, short pair_number); - -static PyObject * -_curses_pair_content(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - short pair_number; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - long ival = PyLong_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - goto exit; - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - goto exit; - } - else { - pair_number = (short) ival; - } - } - return_value = _curses_pair_content_impl(module, pair_number); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_pair_number__doc__, -"pair_number($module, attr, /)\n" -"--\n" -"\n" -"Return the number of the color-pair set by the specified attribute value.\n" -"\n" -"color_pair() is the counterpart to this function."); - -#define _CURSES_PAIR_NUMBER_METHODDEF \ - {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__}, - -static PyObject * -_curses_pair_number_impl(PyObject *module, int attr); - -static PyObject * -_curses_pair_number(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int attr; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - attr = _PyLong_AsInt(arg); - if (attr == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_pair_number_impl(module, attr); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_putp__doc__, -"putp($module, string, /)\n" -"--\n" -"\n" -"Emit the value of a specified terminfo capability for the current terminal.\n" -"\n" -"Note that the output of putp() always goes to standard output."); - -#define _CURSES_PUTP_METHODDEF \ - {"putp", (PyCFunction)_curses_putp, METH_O, _curses_putp__doc__}, - -static PyObject * -_curses_putp_impl(PyObject *module, const char *string); - -static PyObject * -_curses_putp(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - const char *string; - - if (!PyArg_Parse(arg, "y:putp", &string)) { - goto exit; - } - return_value = _curses_putp_impl(module, string); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_qiflush__doc__, -"qiflush($module, flag=True, /)\n" -"--\n" -"\n" -"Enable queue flushing.\n" -"\n" -" flag\n" -" If false, the effect is the same as calling noqiflush().\n" -"\n" -"If queue flushing is enabled, all output in the display driver queue\n" -"will be flushed when the INTR, QUIT and SUSP characters are read."); - -#define _CURSES_QIFLUSH_METHODDEF \ - {"qiflush", (PyCFunction)(void(*)(void))_curses_qiflush, METH_FASTCALL, _curses_qiflush__doc__}, - -static PyObject * -_curses_qiflush_impl(PyObject *module, int flag); - -static PyObject * -_curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[0]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_qiflush_impl(module, flag); - -exit: - return return_value; -} - -#if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) - -PyDoc_STRVAR(_curses_update_lines_cols__doc__, -"update_lines_cols($module, /)\n" -"--\n" -"\n"); - -#define _CURSES_UPDATE_LINES_COLS_METHODDEF \ - {"update_lines_cols", (PyCFunction)_curses_update_lines_cols, METH_NOARGS, _curses_update_lines_cols__doc__}, - -static PyObject * -_curses_update_lines_cols_impl(PyObject *module); - -static PyObject * -_curses_update_lines_cols(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_update_lines_cols_impl(module); -} - -#endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */ - -PyDoc_STRVAR(_curses_raw__doc__, -"raw($module, flag=True, /)\n" -"--\n" -"\n" -"Enter raw mode.\n" -"\n" -" flag\n" -" If false, the effect is the same as calling noraw().\n" -"\n" -"In raw mode, normal line buffering and processing of interrupt, quit,\n" -"suspend, and flow control keys are turned off; characters are presented to\n" -"curses input functions one by one."); - -#define _CURSES_RAW_METHODDEF \ - {"raw", (PyCFunction)(void(*)(void))_curses_raw, METH_FASTCALL, _curses_raw__doc__}, - -static PyObject * -_curses_raw_impl(PyObject *module, int flag); - -static PyObject * -_curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[0]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _curses_raw_impl(module, flag); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_reset_prog_mode__doc__, -"reset_prog_mode($module, /)\n" -"--\n" -"\n" -"Restore the terminal to \"program\" mode, as previously saved by def_prog_mode()."); - -#define _CURSES_RESET_PROG_MODE_METHODDEF \ - {"reset_prog_mode", (PyCFunction)_curses_reset_prog_mode, METH_NOARGS, _curses_reset_prog_mode__doc__}, - -static PyObject * -_curses_reset_prog_mode_impl(PyObject *module); - -static PyObject * -_curses_reset_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_reset_prog_mode_impl(module); -} - -PyDoc_STRVAR(_curses_reset_shell_mode__doc__, -"reset_shell_mode($module, /)\n" -"--\n" -"\n" -"Restore the terminal to \"shell\" mode, as previously saved by def_shell_mode()."); - -#define _CURSES_RESET_SHELL_MODE_METHODDEF \ - {"reset_shell_mode", (PyCFunction)_curses_reset_shell_mode, METH_NOARGS, _curses_reset_shell_mode__doc__}, - -static PyObject * -_curses_reset_shell_mode_impl(PyObject *module); - -static PyObject * -_curses_reset_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_reset_shell_mode_impl(module); -} - -PyDoc_STRVAR(_curses_resetty__doc__, -"resetty($module, /)\n" -"--\n" -"\n" -"Restore terminal mode."); - -#define _CURSES_RESETTY_METHODDEF \ - {"resetty", (PyCFunction)_curses_resetty, METH_NOARGS, _curses_resetty__doc__}, - -static PyObject * -_curses_resetty_impl(PyObject *module); - -static PyObject * -_curses_resetty(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_resetty_impl(module); -} - -#if defined(HAVE_CURSES_RESIZETERM) - -PyDoc_STRVAR(_curses_resizeterm__doc__, -"resizeterm($module, nlines, ncols, /)\n" -"--\n" -"\n" -"Resize the standard and current windows to the specified dimensions.\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width.\n" -"\n" -"Adjusts other bookkeeping data used by the curses library that record the\n" -"window dimensions (in particular the SIGWINCH handler)."); - -#define _CURSES_RESIZETERM_METHODDEF \ - {"resizeterm", (PyCFunction)(void(*)(void))_curses_resizeterm, METH_FASTCALL, _curses_resizeterm__doc__}, - -static PyObject * -_curses_resizeterm_impl(PyObject *module, int nlines, int ncols); - -static PyObject * -_curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int nlines; - int ncols; - - if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nlines = _PyLong_AsInt(args[0]); - if (nlines == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ncols = _PyLong_AsInt(args[1]); - if (ncols == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_resizeterm_impl(module, nlines, ncols); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_RESIZETERM) */ - -#if defined(HAVE_CURSES_RESIZE_TERM) - -PyDoc_STRVAR(_curses_resize_term__doc__, -"resize_term($module, nlines, ncols, /)\n" -"--\n" -"\n" -"Backend function used by resizeterm(), performing most of the work.\n" -"\n" -" nlines\n" -" Height.\n" -" ncols\n" -" Width.\n" -"\n" -"When resizing the windows, resize_term() blank-fills the areas that are\n" -"extended. The calling application should fill in these areas with appropriate\n" -"data. The resize_term() function attempts to resize all windows. However,\n" -"due to the calling convention of pads, it is not possible to resize these\n" -"without additional interaction with the application."); - -#define _CURSES_RESIZE_TERM_METHODDEF \ - {"resize_term", (PyCFunction)(void(*)(void))_curses_resize_term, METH_FASTCALL, _curses_resize_term__doc__}, - -static PyObject * -_curses_resize_term_impl(PyObject *module, int nlines, int ncols); - -static PyObject * -_curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int nlines; - int ncols; - - if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nlines = _PyLong_AsInt(args[0]); - if (nlines == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - ncols = _PyLong_AsInt(args[1]); - if (ncols == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_resize_term_impl(module, nlines, ncols); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_RESIZE_TERM) */ - -PyDoc_STRVAR(_curses_savetty__doc__, -"savetty($module, /)\n" -"--\n" -"\n" -"Save terminal mode."); - -#define _CURSES_SAVETTY_METHODDEF \ - {"savetty", (PyCFunction)_curses_savetty, METH_NOARGS, _curses_savetty__doc__}, - -static PyObject * -_curses_savetty_impl(PyObject *module); - -static PyObject * -_curses_savetty(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_savetty_impl(module); -} - -#if defined(getsyx) - -PyDoc_STRVAR(_curses_setsyx__doc__, -"setsyx($module, y, x, /)\n" -"--\n" -"\n" -"Set the virtual screen cursor.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -"\n" -"If y and x are both -1, then leaveok is set."); - -#define _CURSES_SETSYX_METHODDEF \ - {"setsyx", (PyCFunction)(void(*)(void))_curses_setsyx, METH_FASTCALL, _curses_setsyx__doc__}, - -static PyObject * -_curses_setsyx_impl(PyObject *module, int y, int x); - -static PyObject * -_curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int y; - int x; - - if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - y = _PyLong_AsInt(args[0]); - if (y == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - x = _PyLong_AsInt(args[1]); - if (x == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_setsyx_impl(module, y, x); - -exit: - return return_value; -} - -#endif /* defined(getsyx) */ - -PyDoc_STRVAR(_curses_start_color__doc__, -"start_color($module, /)\n" -"--\n" -"\n" -"Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.\n" -"\n" -"Must be called if the programmer wants to use colors, and before any other\n" -"color manipulation routine is called. It is good practice to call this\n" -"routine right after initscr().\n" -"\n" -"It also restores the colors on the terminal to the values they had when the\n" -"terminal was just turned on."); - -#define _CURSES_START_COLOR_METHODDEF \ - {"start_color", (PyCFunction)_curses_start_color, METH_NOARGS, _curses_start_color__doc__}, - -static PyObject * -_curses_start_color_impl(PyObject *module); - -static PyObject * -_curses_start_color(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_start_color_impl(module); -} - -PyDoc_STRVAR(_curses_termattrs__doc__, -"termattrs($module, /)\n" -"--\n" -"\n" -"Return a logical OR of all video attributes supported by the terminal."); - -#define _CURSES_TERMATTRS_METHODDEF \ - {"termattrs", (PyCFunction)_curses_termattrs, METH_NOARGS, _curses_termattrs__doc__}, - -static PyObject * -_curses_termattrs_impl(PyObject *module); - -static PyObject * -_curses_termattrs(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_termattrs_impl(module); -} - -PyDoc_STRVAR(_curses_termname__doc__, -"termname($module, /)\n" -"--\n" -"\n" -"Return the value of the environment variable TERM, truncated to 14 characters."); - -#define _CURSES_TERMNAME_METHODDEF \ - {"termname", (PyCFunction)_curses_termname, METH_NOARGS, _curses_termname__doc__}, - -static PyObject * -_curses_termname_impl(PyObject *module); - -static PyObject * -_curses_termname(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_termname_impl(module); -} - -PyDoc_STRVAR(_curses_tigetflag__doc__, -"tigetflag($module, capname, /)\n" -"--\n" -"\n" -"Return the value of the Boolean capability.\n" -"\n" -" capname\n" -" The terminfo capability name.\n" -"\n" -"The value -1 is returned if capname is not a Boolean capability, or 0 if\n" -"it is canceled or absent from the terminal description."); - -#define _CURSES_TIGETFLAG_METHODDEF \ - {"tigetflag", (PyCFunction)_curses_tigetflag, METH_O, _curses_tigetflag__doc__}, - -static PyObject * -_curses_tigetflag_impl(PyObject *module, const char *capname); - -static PyObject * -_curses_tigetflag(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - const char *capname; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("tigetflag", "argument", "str", arg); - goto exit; - } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); - if (capname == NULL) { - goto exit; - } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - return_value = _curses_tigetflag_impl(module, capname); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_tigetnum__doc__, -"tigetnum($module, capname, /)\n" -"--\n" -"\n" -"Return the value of the numeric capability.\n" -"\n" -" capname\n" -" The terminfo capability name.\n" -"\n" -"The value -2 is returned if capname is not a numeric capability, or -1 if\n" -"it is canceled or absent from the terminal description."); - -#define _CURSES_TIGETNUM_METHODDEF \ - {"tigetnum", (PyCFunction)_curses_tigetnum, METH_O, _curses_tigetnum__doc__}, - -static PyObject * -_curses_tigetnum_impl(PyObject *module, const char *capname); - -static PyObject * -_curses_tigetnum(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - const char *capname; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("tigetnum", "argument", "str", arg); - goto exit; - } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); - if (capname == NULL) { - goto exit; - } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - return_value = _curses_tigetnum_impl(module, capname); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_tigetstr__doc__, -"tigetstr($module, capname, /)\n" -"--\n" -"\n" -"Return the value of the string capability.\n" -"\n" -" capname\n" -" The terminfo capability name.\n" -"\n" -"None is returned if capname is not a string capability, or is canceled or\n" -"absent from the terminal description."); - -#define _CURSES_TIGETSTR_METHODDEF \ - {"tigetstr", (PyCFunction)_curses_tigetstr, METH_O, _curses_tigetstr__doc__}, - -static PyObject * -_curses_tigetstr_impl(PyObject *module, const char *capname); - -static PyObject * -_curses_tigetstr(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - const char *capname; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("tigetstr", "argument", "str", arg); - goto exit; - } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); - if (capname == NULL) { - goto exit; - } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - return_value = _curses_tigetstr_impl(module, capname); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_tparm__doc__, -"tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n" -" i9=0, /)\n" -"--\n" -"\n" -"Instantiate the specified byte string with the supplied parameters.\n" -"\n" -" str\n" -" Parameterized byte string obtained from the terminfo database."); - -#define _CURSES_TPARM_METHODDEF \ - {"tparm", (PyCFunction)(void(*)(void))_curses_tparm, METH_FASTCALL, _curses_tparm__doc__}, - -static PyObject * -_curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, - int i4, int i5, int i6, int i7, int i8, int i9); - -static PyObject * -_curses_tparm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const char *str; - int i1 = 0; - int i2 = 0; - int i3 = 0; - int i4 = 0; - int i5 = 0; - int i6 = 0; - int i7 = 0; - int i8 = 0; - int i9 = 0; - - if (!_PyArg_ParseStack(args, nargs, "y|iiiiiiiii:tparm", - &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) { - goto exit; - } - return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9); - -exit: - return return_value; -} - -#if defined(HAVE_CURSES_TYPEAHEAD) - -PyDoc_STRVAR(_curses_typeahead__doc__, -"typeahead($module, fd, /)\n" -"--\n" -"\n" -"Specify that the file descriptor fd be used for typeahead checking.\n" -"\n" -" fd\n" -" File descriptor.\n" -"\n" -"If fd is -1, then no typeahead checking is done."); - -#define _CURSES_TYPEAHEAD_METHODDEF \ - {"typeahead", (PyCFunction)_curses_typeahead, METH_O, _curses_typeahead__doc__}, - -static PyObject * -_curses_typeahead_impl(PyObject *module, int fd); - -static PyObject * -_curses_typeahead(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_typeahead_impl(module, fd); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_TYPEAHEAD) */ - -PyDoc_STRVAR(_curses_unctrl__doc__, -"unctrl($module, ch, /)\n" -"--\n" -"\n" -"Return a string which is a printable representation of the character ch.\n" -"\n" -"Control characters are displayed as a caret followed by the character,\n" -"for example as ^C. Printing characters are left as they are."); - -#define _CURSES_UNCTRL_METHODDEF \ - {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__}, - -PyDoc_STRVAR(_curses_ungetch__doc__, -"ungetch($module, ch, /)\n" -"--\n" -"\n" -"Push ch so the next getch() will return it."); - -#define _CURSES_UNGETCH_METHODDEF \ - {"ungetch", (PyCFunction)_curses_ungetch, METH_O, _curses_ungetch__doc__}, - -#if defined(HAVE_NCURSESW) - -PyDoc_STRVAR(_curses_unget_wch__doc__, -"unget_wch($module, ch, /)\n" -"--\n" -"\n" -"Push ch so the next get_wch() will return it."); - -#define _CURSES_UNGET_WCH_METHODDEF \ - {"unget_wch", (PyCFunction)_curses_unget_wch, METH_O, _curses_unget_wch__doc__}, - -#endif /* defined(HAVE_NCURSESW) */ - -#if defined(HAVE_CURSES_USE_ENV) - -PyDoc_STRVAR(_curses_use_env__doc__, -"use_env($module, flag, /)\n" -"--\n" -"\n" -"Use environment variables LINES and COLUMNS.\n" -"\n" -"If used, this function should be called before initscr() or newterm() are\n" -"called.\n" -"\n" -"When flag is False, the values of lines and columns specified in the terminfo\n" -"database will be used, even if environment variables LINES and COLUMNS (used\n" -"by default) are set, or if curses is running in a window (in which case\n" -"default behavior would be to use the window size if LINES and COLUMNS are\n" -"not set)."); - -#define _CURSES_USE_ENV_METHODDEF \ - {"use_env", (PyCFunction)_curses_use_env, METH_O, _curses_use_env__doc__}, - -static PyObject * -_curses_use_env_impl(PyObject *module, int flag); - -static PyObject * -_curses_use_env(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int flag; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(arg); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_use_env_impl(module, flag); - -exit: - return return_value; -} - -#endif /* defined(HAVE_CURSES_USE_ENV) */ - -#if !defined(STRICT_SYSV_CURSES) - -PyDoc_STRVAR(_curses_use_default_colors__doc__, -"use_default_colors($module, /)\n" -"--\n" -"\n" -"Allow use of default values for colors on terminals supporting this feature.\n" -"\n" -"Use this to support transparency in your application. The default color\n" -"is assigned to the color number -1."); - -#define _CURSES_USE_DEFAULT_COLORS_METHODDEF \ - {"use_default_colors", (PyCFunction)_curses_use_default_colors, METH_NOARGS, _curses_use_default_colors__doc__}, - -static PyObject * -_curses_use_default_colors_impl(PyObject *module); - -static PyObject * -_curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_use_default_colors_impl(module); -} - -#endif /* !defined(STRICT_SYSV_CURSES) */ - -#ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF - #define _CURSES_WINDOW_ENCLOSE_METHODDEF -#endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */ - -#ifndef _CURSES_WINDOW_GET_WCH_METHODDEF - #define _CURSES_WINDOW_GET_WCH_METHODDEF -#endif /* !defined(_CURSES_WINDOW_GET_WCH_METHODDEF) */ - -#ifndef _CURSES_WINDOW_NOUTREFRESH_METHODDEF - #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF -#endif /* !defined(_CURSES_WINDOW_NOUTREFRESH_METHODDEF) */ - -#ifndef _CURSES_FILTER_METHODDEF - #define _CURSES_FILTER_METHODDEF -#endif /* !defined(_CURSES_FILTER_METHODDEF) */ - -#ifndef _CURSES_GETSYX_METHODDEF - #define _CURSES_GETSYX_METHODDEF -#endif /* !defined(_CURSES_GETSYX_METHODDEF) */ - -#ifndef _CURSES_GETMOUSE_METHODDEF - #define _CURSES_GETMOUSE_METHODDEF -#endif /* !defined(_CURSES_GETMOUSE_METHODDEF) */ - -#ifndef _CURSES_UNGETMOUSE_METHODDEF - #define _CURSES_UNGETMOUSE_METHODDEF -#endif /* !defined(_CURSES_UNGETMOUSE_METHODDEF) */ - -#ifndef _CURSES_HAS_KEY_METHODDEF - #define _CURSES_HAS_KEY_METHODDEF -#endif /* !defined(_CURSES_HAS_KEY_METHODDEF) */ - -#ifndef _CURSES_GET_ESCDELAY_METHODDEF - #define _CURSES_GET_ESCDELAY_METHODDEF -#endif /* !defined(_CURSES_GET_ESCDELAY_METHODDEF) */ - -#ifndef _CURSES_SET_ESCDELAY_METHODDEF - #define _CURSES_SET_ESCDELAY_METHODDEF -#endif /* !defined(_CURSES_SET_ESCDELAY_METHODDEF) */ - -#ifndef _CURSES_GET_TABSIZE_METHODDEF - #define _CURSES_GET_TABSIZE_METHODDEF -#endif /* !defined(_CURSES_GET_TABSIZE_METHODDEF) */ - -#ifndef _CURSES_SET_TABSIZE_METHODDEF - #define _CURSES_SET_TABSIZE_METHODDEF -#endif /* !defined(_CURSES_SET_TABSIZE_METHODDEF) */ - -#ifndef _CURSES_IS_TERM_RESIZED_METHODDEF - #define _CURSES_IS_TERM_RESIZED_METHODDEF -#endif /* !defined(_CURSES_IS_TERM_RESIZED_METHODDEF) */ - -#ifndef _CURSES_MOUSEINTERVAL_METHODDEF - #define _CURSES_MOUSEINTERVAL_METHODDEF -#endif /* !defined(_CURSES_MOUSEINTERVAL_METHODDEF) */ - -#ifndef _CURSES_MOUSEMASK_METHODDEF - #define _CURSES_MOUSEMASK_METHODDEF -#endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */ - -#ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF - #define _CURSES_UPDATE_LINES_COLS_METHODDEF -#endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */ - -#ifndef _CURSES_RESIZETERM_METHODDEF - #define _CURSES_RESIZETERM_METHODDEF -#endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */ - -#ifndef _CURSES_RESIZE_TERM_METHODDEF - #define _CURSES_RESIZE_TERM_METHODDEF -#endif /* !defined(_CURSES_RESIZE_TERM_METHODDEF) */ - -#ifndef _CURSES_SETSYX_METHODDEF - #define _CURSES_SETSYX_METHODDEF -#endif /* !defined(_CURSES_SETSYX_METHODDEF) */ - -#ifndef _CURSES_TYPEAHEAD_METHODDEF - #define _CURSES_TYPEAHEAD_METHODDEF -#endif /* !defined(_CURSES_TYPEAHEAD_METHODDEF) */ - -#ifndef _CURSES_UNGET_WCH_METHODDEF - #define _CURSES_UNGET_WCH_METHODDEF -#endif /* !defined(_CURSES_UNGET_WCH_METHODDEF) */ - -#ifndef _CURSES_USE_ENV_METHODDEF - #define _CURSES_USE_ENV_METHODDEF -#endif /* !defined(_CURSES_USE_ENV_METHODDEF) */ - -#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF - #define _CURSES_USE_DEFAULT_COLORS_METHODDEF -#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=5e739120041df368 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_curses_window_addstr__doc__, +"addstr([y, x,] str, [attr])\n" +"Paint the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to add.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Paint the string str at (y, x) with attributes attr,\n" +"overwriting anything previously on the display.\n" +"By default, the character position and attributes are the\n" +"current settings for the window object."); + +#define _CURSES_WINDOW_ADDSTR_METHODDEF \ + {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__}, + +static PyObject * +_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr); + +static PyObject * +_curses_window_addstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:addstr", &str)) { + goto exit; + } + break; + case 2: + if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 3: + if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) { + goto exit; + } + group_left_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); + goto exit; + } + return_value = _curses_window_addstr_impl(self, group_left_1, y, x, str, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_addnstr__doc__, +"addnstr([y, x,] str, n, [attr])\n" +"Paint at most n characters of the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to add.\n" +" n\n" +" Maximal number of characters.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Paint at most n characters of the string str at (y, x) with\n" +"attributes attr, overwriting anything previously on the display.\n" +"By default, the character position and attributes are the\n" +"current settings for the window object."); + +#define _CURSES_WINDOW_ADDNSTR_METHODDEF \ + {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__}, + +static PyObject * +_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_addnstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int n; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) { + goto exit; + } + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_addnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_bkgd__doc__, +"bkgd($self, ch, attr=_curses.A_NORMAL, /)\n" +"--\n" +"\n" +"Set the background property of the window.\n" +"\n" +" ch\n" +" Background character.\n" +" attr\n" +" Background attributes."); + +#define _CURSES_WINDOW_BKGD_METHODDEF \ + {"bkgd", (PyCFunction)(void(*)(void))_curses_window_bkgd, METH_FASTCALL, _curses_window_bkgd__doc__}, + +static PyObject * +_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr); + +static PyObject * +_curses_window_bkgd(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) { + goto exit; + } + ch = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(args[1]); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_window_bkgd_impl(self, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attroff__doc__, +"attroff($self, attr, /)\n" +"--\n" +"\n" +"Remove attribute attr from the \"background\" set."); + +#define _CURSES_WINDOW_ATTROFF_METHODDEF \ + {"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__}, + +static PyObject * +_curses_window_attroff_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attroff(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(arg); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_attroff_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attron__doc__, +"attron($self, attr, /)\n" +"--\n" +"\n" +"Add attribute attr from the \"background\" set."); + +#define _CURSES_WINDOW_ATTRON_METHODDEF \ + {"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__}, + +static PyObject * +_curses_window_attron_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attron(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(arg); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_attron_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attrset__doc__, +"attrset($self, attr, /)\n" +"--\n" +"\n" +"Set the \"background\" set of attributes."); + +#define _CURSES_WINDOW_ATTRSET_METHODDEF \ + {"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__}, + +static PyObject * +_curses_window_attrset_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attrset(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(arg); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_attrset_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_bkgdset__doc__, +"bkgdset($self, ch, attr=_curses.A_NORMAL, /)\n" +"--\n" +"\n" +"Set the window\'s background.\n" +"\n" +" ch\n" +" Background character.\n" +" attr\n" +" Background attributes."); + +#define _CURSES_WINDOW_BKGDSET_METHODDEF \ + {"bkgdset", (PyCFunction)(void(*)(void))_curses_window_bkgdset, METH_FASTCALL, _curses_window_bkgdset__doc__}, + +static PyObject * +_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, + long attr); + +static PyObject * +_curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) { + goto exit; + } + ch = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(args[1]); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_window_bkgdset_impl(self, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_border__doc__, +"border($self, ls=_curses.ACS_VLINE, rs=_curses.ACS_VLINE,\n" +" ts=_curses.ACS_HLINE, bs=_curses.ACS_HLINE,\n" +" tl=_curses.ACS_ULCORNER, tr=_curses.ACS_URCORNER,\n" +" bl=_curses.ACS_LLCORNER, br=_curses.ACS_LRCORNER, /)\n" +"--\n" +"\n" +"Draw a border around the edges of the window.\n" +"\n" +" ls\n" +" Left side.\n" +" rs\n" +" Right side.\n" +" ts\n" +" Top side.\n" +" bs\n" +" Bottom side.\n" +" tl\n" +" Upper-left corner.\n" +" tr\n" +" Upper-right corner.\n" +" bl\n" +" Bottom-left corner.\n" +" br\n" +" Bottom-right corner.\n" +"\n" +"Each parameter specifies the character to use for a specific part of the\n" +"border. The characters can be specified as integers or as one-character\n" +"strings. A 0 value for any parameter will cause the default character to be\n" +"used for that parameter."); + +#define _CURSES_WINDOW_BORDER_METHODDEF \ + {"border", (PyCFunction)(void(*)(void))_curses_window_border, METH_FASTCALL, _curses_window_border__doc__}, + +static PyObject * +_curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, + PyObject *rs, PyObject *ts, PyObject *bs, + PyObject *tl, PyObject *tr, PyObject *bl, + PyObject *br); + +static PyObject * +_curses_window_border(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ls = NULL; + PyObject *rs = NULL; + PyObject *ts = NULL; + PyObject *bs = NULL; + PyObject *tl = NULL; + PyObject *tr = NULL; + PyObject *bl = NULL; + PyObject *br = NULL; + + if (!_PyArg_CheckPositional("border", nargs, 0, 8)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + ls = args[0]; + if (nargs < 2) { + goto skip_optional; + } + rs = args[1]; + if (nargs < 3) { + goto skip_optional; + } + ts = args[2]; + if (nargs < 4) { + goto skip_optional; + } + bs = args[3]; + if (nargs < 5) { + goto skip_optional; + } + tl = args[4]; + if (nargs < 6) { + goto skip_optional; + } + tr = args[5]; + if (nargs < 7) { + goto skip_optional; + } + bl = args[6]; + if (nargs < 8) { + goto skip_optional; + } + br = args[7]; +skip_optional: + return_value = _curses_window_border_impl(self, ls, rs, ts, bs, tl, tr, bl, br); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_box__doc__, +"box([verch=0, horch=0])\n" +"Draw a border around the edges of the window.\n" +"\n" +" verch\n" +" Left and right side.\n" +" horch\n" +" Top and bottom side.\n" +"\n" +"Similar to border(), but both ls and rs are verch and both ts and bs are\n" +"horch. The default corner characters are always used by this function."); + +#define _CURSES_WINDOW_BOX_METHODDEF \ + {"box", (PyCFunction)_curses_window_box, METH_VARARGS, _curses_window_box__doc__}, + +static PyObject * +_curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, + PyObject *verch, PyObject *horch); + +static PyObject * +_curses_window_box(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + PyObject *verch = _PyLong_Zero; + PyObject *horch = _PyLong_Zero; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "OO:box", &verch, &horch)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.box requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_box_impl(self, group_right_1, verch, horch); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_delch__doc__, +"delch([y, x])\n" +"Delete any character at (y, x).\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate."); + +#define _CURSES_WINDOW_DELCH_METHODDEF \ + {"delch", (PyCFunction)_curses_window_delch, METH_VARARGS, _curses_window_delch__doc__}, + +static PyObject * +_curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_delch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:delch", &y, &x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.delch requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_delch_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_derwin__doc__, +"derwin([nlines=0, ncols=0,] begin_y, begin_x)\n" +"Create a sub-window (window-relative coordinates).\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"derwin() is the same as calling subwin(), except that begin_y and begin_x\n" +"are relative to the origin of the window, rather than relative to the entire\n" +"screen."); + +#define _CURSES_WINDOW_DERWIN_METHODDEF \ + {"derwin", (PyCFunction)_curses_window_derwin, METH_VARARGS, _curses_window_derwin__doc__}, + +static PyObject * +_curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x); + +static PyObject * +_curses_window_derwin(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int nlines = 0; + int ncols = 0; + int begin_y; + int begin_x; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:derwin", &begin_y, &begin_x)) { + goto exit; + } + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:derwin", &nlines, &ncols, &begin_y, &begin_x)) { + goto exit; + } + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.derwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_derwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_echochar__doc__, +"echochar($self, ch, attr=_curses.A_NORMAL, /)\n" +"--\n" +"\n" +"Add character ch with attribute attr, and refresh.\n" +"\n" +" ch\n" +" Character to add.\n" +" attr\n" +" Attributes for the character."); + +#define _CURSES_WINDOW_ECHOCHAR_METHODDEF \ + {"echochar", (PyCFunction)(void(*)(void))_curses_window_echochar, METH_FASTCALL, _curses_window_echochar__doc__}, + +static PyObject * +_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, + long attr); + +static PyObject * +_curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) { + goto exit; + } + ch = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = PyLong_AsLong(args[1]); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_window_echochar_impl(self, ch, attr); + +exit: + return return_value; +} + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_window_enclose__doc__, +"enclose($self, y, x, /)\n" +"--\n" +"\n" +"Return True if the screen-relative coordinates are enclosed by the window.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate."); + +#define _CURSES_WINDOW_ENCLOSE_METHODDEF \ + {"enclose", (PyCFunction)(void(*)(void))_curses_window_enclose, METH_FASTCALL, _curses_window_enclose__doc__}, + +static long +_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x); + +static PyObject * +_curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int y; + int x; + long _return_value; + + if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + y = _PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + x = _PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + _return_value = _curses_window_enclose_impl(self, y, x); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_window_getbkgd__doc__, +"getbkgd($self, /)\n" +"--\n" +"\n" +"Return the window\'s current background character/attribute pair."); + +#define _CURSES_WINDOW_GETBKGD_METHODDEF \ + {"getbkgd", (PyCFunction)_curses_window_getbkgd, METH_NOARGS, _curses_window_getbkgd__doc__}, + +static long +_curses_window_getbkgd_impl(PyCursesWindowObject *self); + +static PyObject * +_curses_window_getbkgd(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + long _return_value; + + _return_value = _curses_window_getbkgd_impl(self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_getch__doc__, +"getch([y, x])\n" +"Get a character code from terminal keyboard.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"The integer returned does not have to be in ASCII range: function keys,\n" +"keypad keys and so on return numbers higher than 256. In no-delay mode, -1\n" +"is returned if there is no input, else getch() waits until a key is pressed."); + +#define _CURSES_WINDOW_GETCH_METHODDEF \ + {"getch", (PyCFunction)_curses_window_getch, METH_VARARGS, _curses_window_getch__doc__}, + +static int +_curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_getch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + int _return_value; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:getch", &y, &x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.getch requires 0 to 2 arguments"); + goto exit; + } + _return_value = _curses_window_getch_impl(self, group_right_1, y, x); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_getkey__doc__, +"getkey([y, x])\n" +"Get a character (string) from terminal keyboard.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"Returning a string instead of an integer, as getch() does. Function keys,\n" +"keypad keys and other special keys return a multibyte string containing the\n" +"key name. In no-delay mode, an exception is raised if there is no input."); + +#define _CURSES_WINDOW_GETKEY_METHODDEF \ + {"getkey", (PyCFunction)_curses_window_getkey, METH_VARARGS, _curses_window_getkey__doc__}, + +static PyObject * +_curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_getkey(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:getkey", &y, &x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.getkey requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_getkey_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +#if defined(HAVE_NCURSESW) + +PyDoc_STRVAR(_curses_window_get_wch__doc__, +"get_wch([y, x])\n" +"Get a wide character from terminal keyboard.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"Return a character for most keys, or an integer for function keys,\n" +"keypad keys, and other special keys."); + +#define _CURSES_WINDOW_GET_WCH_METHODDEF \ + {"get_wch", (PyCFunction)_curses_window_get_wch, METH_VARARGS, _curses_window_get_wch__doc__}, + +static PyObject * +_curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_get_wch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:get_wch", &y, &x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.get_wch requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_get_wch_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +#endif /* defined(HAVE_NCURSESW) */ + +PyDoc_STRVAR(_curses_window_hline__doc__, +"hline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n" +"Display a horizontal line.\n" +"\n" +" y\n" +" Starting Y-coordinate.\n" +" x\n" +" Starting X-coordinate.\n" +" ch\n" +" Character to draw.\n" +" n\n" +" Line length.\n" +" attr\n" +" Attributes for the characters."); + +#define _CURSES_WINDOW_HLINE_METHODDEF \ + {"hline", (PyCFunction)_curses_window_hline, METH_VARARGS, _curses_window_hline__doc__}, + +static PyObject * +_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_hline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int n; + int group_right_1 = 0; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:hline", &ch, &n)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:hline", &ch, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:hline", &y, &x, &ch, &n)) { + goto exit; + } + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_hline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insch__doc__, +"insch([y, x,] ch, [attr=_curses.A_NORMAL])\n" +"Insert a character before the current or specified position.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" ch\n" +" Character to insert.\n" +" attr\n" +" Attributes for the character.\n" +"\n" +"All characters to the right of the cursor are shifted one position right, with\n" +"the rightmost characters on the line being lost."); + +#define _CURSES_WINDOW_INSCH_METHODDEF \ + {"insch", (PyCFunction)_curses_window_insch, METH_VARARGS, _curses_window_insch__doc__}, + +static PyObject * +_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int group_right_1, + long attr); + +static PyObject * +_curses_window_insch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int group_right_1 = 0; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:insch", &ch)) { + goto exit; + } + break; + case 2: + if (!PyArg_ParseTuple(args, "Ol:insch", &ch, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 3: + if (!PyArg_ParseTuple(args, "iiO:insch", &y, &x, &ch)) { + goto exit; + } + group_left_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments"); + goto exit; + } + return_value = _curses_window_insch_impl(self, group_left_1, y, x, ch, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_inch__doc__, +"inch([y, x])\n" +"Return the character at the given position in the window.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"The bottom 8 bits are the character proper, and upper bits are the attributes."); + +#define _CURSES_WINDOW_INCH_METHODDEF \ + {"inch", (PyCFunction)_curses_window_inch, METH_VARARGS, _curses_window_inch__doc__}, + +static unsigned long +_curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_inch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + unsigned long _return_value; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:inch", &y, &x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.inch requires 0 to 2 arguments"); + goto exit; + } + _return_value = _curses_window_inch_impl(self, group_right_1, y, x); + if ((_return_value == (unsigned long)-1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromUnsignedLong(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insstr__doc__, +"insstr([y, x,] str, [attr])\n" +"Insert the string before the current or specified position.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to insert.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Insert a character string (as many characters as will fit on the line)\n" +"before the character under the cursor. All characters to the right of\n" +"the cursor are shifted right, with the rightmost characters on the line\n" +"being lost. The cursor position does not change (after moving to y, x,\n" +"if specified)."); + +#define _CURSES_WINDOW_INSSTR_METHODDEF \ + {"insstr", (PyCFunction)_curses_window_insstr, METH_VARARGS, _curses_window_insstr__doc__}, + +static PyObject * +_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr); + +static PyObject * +_curses_window_insstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:insstr", &str)) { + goto exit; + } + break; + case 2: + if (!PyArg_ParseTuple(args, "Ol:insstr", &str, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 3: + if (!PyArg_ParseTuple(args, "iiO:insstr", &y, &x, &str)) { + goto exit; + } + group_left_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); + goto exit; + } + return_value = _curses_window_insstr_impl(self, group_left_1, y, x, str, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insnstr__doc__, +"insnstr([y, x,] str, n, [attr])\n" +"Insert at most n characters of the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to insert.\n" +" n\n" +" Maximal number of characters.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Insert a character string (as many characters as will fit on the line)\n" +"before the character under the cursor, up to n characters. If n is zero\n" +"or negative, the entire string is inserted. All characters to the right\n" +"of the cursor are shifted right, with the rightmost characters on the line\n" +"being lost. The cursor position does not change (after moving to y, x, if\n" +"specified)."); + +#define _CURSES_WINDOW_INSNSTR_METHODDEF \ + {"insnstr", (PyCFunction)_curses_window_insnstr, METH_VARARGS, _curses_window_insnstr__doc__}, + +static PyObject * +_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_insnstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int n; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:insnstr", &str, &n)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:insnstr", &str, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:insnstr", &y, &x, &str, &n)) { + goto exit; + } + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_insnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_is_linetouched__doc__, +"is_linetouched($self, line, /)\n" +"--\n" +"\n" +"Return True if the specified line was modified, otherwise return False.\n" +"\n" +" line\n" +" Line number.\n" +"\n" +"Raise a curses.error exception if line is not valid for the given window."); + +#define _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF \ + {"is_linetouched", (PyCFunction)_curses_window_is_linetouched, METH_O, _curses_window_is_linetouched__doc__}, + +static PyObject * +_curses_window_is_linetouched_impl(PyCursesWindowObject *self, int line); + +static PyObject * +_curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int line; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + line = _PyLong_AsInt(arg); + if (line == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_is_linetouched_impl(self, line); + +exit: + return return_value; +} + +#if defined(py_is_pad) + +PyDoc_STRVAR(_curses_window_noutrefresh__doc__, +"noutrefresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" +"Mark for refresh but wait.\n" +"\n" +"This function updates the data structure representing the desired state of the\n" +"window, but does not force an update of the physical screen. To accomplish\n" +"that, call doupdate()."); + +#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ + {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_VARARGS, _curses_window_noutrefresh__doc__}, + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self, + int group_right_1, int pminrow, int pmincol, + int sminrow, int smincol, int smaxrow, + int smaxcol); + +static PyObject * +_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int pminrow = 0; + int pmincol = 0; + int sminrow = 0; + int smincol = 0; + int smaxrow = 0; + int smaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 6: + if (!PyArg_ParseTuple(args, "iiiiii:noutrefresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.noutrefresh requires 0 to 6 arguments"); + goto exit; + } + return_value = _curses_window_noutrefresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); + +exit: + return return_value; +} + +#endif /* defined(py_is_pad) */ + +#if !defined(py_is_pad) + +PyDoc_STRVAR(_curses_window_noutrefresh__doc__, +"noutrefresh($self, /)\n" +"--\n" +"\n" +"Mark for refresh but wait.\n" +"\n" +"This function updates the data structure representing the desired state of the\n" +"window, but does not force an update of the physical screen. To accomplish\n" +"that, call doupdate()."); + +#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ + {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_NOARGS, _curses_window_noutrefresh__doc__}, + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self); + +static PyObject * +_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_window_noutrefresh_impl(self); +} + +#endif /* !defined(py_is_pad) */ + +PyDoc_STRVAR(_curses_window_overlay__doc__, +"overlay(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])\n" +"Overlay the window on top of destwin.\n" +"\n" +"The windows need not be the same size, only the overlapping region is copied.\n" +"This copy is non-destructive, which means that the current background\n" +"character does not overwrite the old contents of destwin.\n" +"\n" +"To get fine-grained control over the copied region, the second form of\n" +"overlay() can be used. sminrow and smincol are the upper-left coordinates\n" +"of the source window, and the other variables mark a rectangle in the\n" +"destination window."); + +#define _CURSES_WINDOW_OVERLAY_METHODDEF \ + {"overlay", (PyCFunction)_curses_window_overlay, METH_VARARGS, _curses_window_overlay__doc__}, + +static PyObject * +_curses_window_overlay_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, int group_right_1, + int sminrow, int smincol, int dminrow, + int dmincol, int dmaxrow, int dmaxcol); + +static PyObject * +_curses_window_overlay(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *destwin; + int group_right_1 = 0; + int sminrow = 0; + int smincol = 0; + int dminrow = 0; + int dmincol = 0; + int dmaxrow = 0; + int dmaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!:overlay", &PyCursesWindow_Type, &destwin)) { + goto exit; + } + break; + case 7: + if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.overlay requires 1 to 7 arguments"); + goto exit; + } + return_value = _curses_window_overlay_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_overwrite__doc__, +"overwrite(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow,\n" +" dmaxcol])\n" +"Overwrite the window on top of destwin.\n" +"\n" +"The windows need not be the same size, in which case only the overlapping\n" +"region is copied. This copy is destructive, which means that the current\n" +"background character overwrites the old contents of destwin.\n" +"\n" +"To get fine-grained control over the copied region, the second form of\n" +"overwrite() can be used. sminrow and smincol are the upper-left coordinates\n" +"of the source window, the other variables mark a rectangle in the destination\n" +"window."); + +#define _CURSES_WINDOW_OVERWRITE_METHODDEF \ + {"overwrite", (PyCFunction)_curses_window_overwrite, METH_VARARGS, _curses_window_overwrite__doc__}, + +static PyObject * +_curses_window_overwrite_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, + int group_right_1, int sminrow, int smincol, + int dminrow, int dmincol, int dmaxrow, + int dmaxcol); + +static PyObject * +_curses_window_overwrite(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *destwin; + int group_right_1 = 0; + int sminrow = 0; + int smincol = 0; + int dminrow = 0; + int dmincol = 0; + int dmaxrow = 0; + int dmaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!:overwrite", &PyCursesWindow_Type, &destwin)) { + goto exit; + } + break; + case 7: + if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.overwrite requires 1 to 7 arguments"); + goto exit; + } + return_value = _curses_window_overwrite_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_putwin__doc__, +"putwin($self, file, /)\n" +"--\n" +"\n" +"Write all data associated with the window into the provided file object.\n" +"\n" +"This information can be later retrieved using the getwin() function."); + +#define _CURSES_WINDOW_PUTWIN_METHODDEF \ + {"putwin", (PyCFunction)_curses_window_putwin, METH_O, _curses_window_putwin__doc__}, + +PyDoc_STRVAR(_curses_window_redrawln__doc__, +"redrawln($self, beg, num, /)\n" +"--\n" +"\n" +"Mark the specified lines corrupted.\n" +"\n" +" beg\n" +" Starting line number.\n" +" num\n" +" The number of lines.\n" +"\n" +"They should be completely redrawn on the next refresh() call."); + +#define _CURSES_WINDOW_REDRAWLN_METHODDEF \ + {"redrawln", (PyCFunction)(void(*)(void))_curses_window_redrawln, METH_FASTCALL, _curses_window_redrawln__doc__}, + +static PyObject * +_curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num); + +static PyObject * +_curses_window_redrawln(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int beg; + int num; + + if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + beg = _PyLong_AsInt(args[0]); + if (beg == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + num = _PyLong_AsInt(args[1]); + if (num == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_redrawln_impl(self, beg, num); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_refresh__doc__, +"refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" +"Update the display immediately.\n" +"\n" +"Synchronize actual screen with previous drawing/deleting methods.\n" +"The 6 optional arguments can only be specified when the window is a pad\n" +"created with newpad(). The additional parameters are needed to indicate\n" +"what part of the pad and screen are involved. pminrow and pmincol specify\n" +"the upper left-hand corner of the rectangle to be displayed in the pad.\n" +"sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to\n" +"be displayed on the screen. The lower right-hand corner of the rectangle to\n" +"be displayed in the pad is calculated from the screen coordinates, since the\n" +"rectangles must be the same size. Both rectangles must be entirely contained\n" +"within their respective structures. Negative values of pminrow, pmincol,\n" +"sminrow, or smincol are treated as if they were zero."); + +#define _CURSES_WINDOW_REFRESH_METHODDEF \ + {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__}, + +static PyObject * +_curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, + int pminrow, int pmincol, int sminrow, + int smincol, int smaxrow, int smaxcol); + +static PyObject * +_curses_window_refresh(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int pminrow = 0; + int pmincol = 0; + int sminrow = 0; + int smincol = 0; + int smaxrow = 0; + int smaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 6: + if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments"); + goto exit; + } + return_value = _curses_window_refresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_setscrreg__doc__, +"setscrreg($self, top, bottom, /)\n" +"--\n" +"\n" +"Define a software scrolling region.\n" +"\n" +" top\n" +" First line number.\n" +" bottom\n" +" Last line number.\n" +"\n" +"All scrolling actions will take place in this region."); + +#define _CURSES_WINDOW_SETSCRREG_METHODDEF \ + {"setscrreg", (PyCFunction)(void(*)(void))_curses_window_setscrreg, METH_FASTCALL, _curses_window_setscrreg__doc__}, + +static PyObject * +_curses_window_setscrreg_impl(PyCursesWindowObject *self, int top, + int bottom); + +static PyObject * +_curses_window_setscrreg(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int top; + int bottom; + + if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + top = _PyLong_AsInt(args[0]); + if (top == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bottom = _PyLong_AsInt(args[1]); + if (bottom == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_window_setscrreg_impl(self, top, bottom); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_subwin__doc__, +"subwin([nlines=0, ncols=0,] begin_y, begin_x)\n" +"Create a sub-window (screen-relative coordinates).\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"By default, the sub-window will extend from the specified position to the\n" +"lower right corner of the window."); + +#define _CURSES_WINDOW_SUBWIN_METHODDEF \ + {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, + +static PyObject * +_curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x); + +static PyObject * +_curses_window_subwin(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int nlines = 0; + int ncols = 0; + int begin_y; + int begin_x; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) { + goto exit; + } + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) { + goto exit; + } + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_subwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_scroll__doc__, +"scroll([lines=1])\n" +"Scroll the screen or scrolling region.\n" +"\n" +" lines\n" +" Number of lines to scroll.\n" +"\n" +"Scroll upward if the argument is positive and downward if it is negative."); + +#define _CURSES_WINDOW_SCROLL_METHODDEF \ + {"scroll", (PyCFunction)_curses_window_scroll, METH_VARARGS, _curses_window_scroll__doc__}, + +static PyObject * +_curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1, + int lines); + +static PyObject * +_curses_window_scroll(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int lines = 1; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 1: + if (!PyArg_ParseTuple(args, "i:scroll", &lines)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments"); + goto exit; + } + return_value = _curses_window_scroll_impl(self, group_right_1, lines); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_touchline__doc__, +"touchline(start, count, [changed=True])\n" +"Pretend count lines have been changed, starting with line start.\n" +"\n" +"If changed is supplied, it specifies whether the affected lines are marked\n" +"as having been changed (changed=True) or unchanged (changed=False)."); + +#define _CURSES_WINDOW_TOUCHLINE_METHODDEF \ + {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__}, + +static PyObject * +_curses_window_touchline_impl(PyCursesWindowObject *self, int start, + int count, int group_right_1, int changed); + +static PyObject * +_curses_window_touchline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int start; + int count; + int group_right_1 = 0; + int changed = 1; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "iii:touchline", &start, &count, &changed)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments"); + goto exit; + } + return_value = _curses_window_touchline_impl(self, start, count, group_right_1, changed); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_vline__doc__, +"vline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n" +"Display a vertical line.\n" +"\n" +" y\n" +" Starting Y-coordinate.\n" +" x\n" +" Starting X-coordinate.\n" +" ch\n" +" Character to draw.\n" +" n\n" +" Line length.\n" +" attr\n" +" Attributes for the character."); + +#define _CURSES_WINDOW_VLINE_METHODDEF \ + {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__}, + +static PyObject * +_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_vline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int n; + int group_right_1 = 0; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:vline", &ch, &n)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:vline", &y, &x, &ch, &n)) { + goto exit; + } + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) { + goto exit; + } + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_vline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr); + +exit: + return return_value; +} + +#if defined(HAVE_CURSES_FILTER) + +PyDoc_STRVAR(_curses_filter__doc__, +"filter($module, /)\n" +"--\n" +"\n"); + +#define _CURSES_FILTER_METHODDEF \ + {"filter", (PyCFunction)_curses_filter, METH_NOARGS, _curses_filter__doc__}, + +static PyObject * +_curses_filter_impl(PyObject *module); + +static PyObject * +_curses_filter(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_filter_impl(module); +} + +#endif /* defined(HAVE_CURSES_FILTER) */ + +PyDoc_STRVAR(_curses_baudrate__doc__, +"baudrate($module, /)\n" +"--\n" +"\n" +"Return the output speed of the terminal in bits per second."); + +#define _CURSES_BAUDRATE_METHODDEF \ + {"baudrate", (PyCFunction)_curses_baudrate, METH_NOARGS, _curses_baudrate__doc__}, + +static PyObject * +_curses_baudrate_impl(PyObject *module); + +static PyObject * +_curses_baudrate(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_baudrate_impl(module); +} + +PyDoc_STRVAR(_curses_beep__doc__, +"beep($module, /)\n" +"--\n" +"\n" +"Emit a short attention sound."); + +#define _CURSES_BEEP_METHODDEF \ + {"beep", (PyCFunction)_curses_beep, METH_NOARGS, _curses_beep__doc__}, + +static PyObject * +_curses_beep_impl(PyObject *module); + +static PyObject * +_curses_beep(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_beep_impl(module); +} + +PyDoc_STRVAR(_curses_can_change_color__doc__, +"can_change_color($module, /)\n" +"--\n" +"\n" +"Return True if the programmer can change the colors displayed by the terminal."); + +#define _CURSES_CAN_CHANGE_COLOR_METHODDEF \ + {"can_change_color", (PyCFunction)_curses_can_change_color, METH_NOARGS, _curses_can_change_color__doc__}, + +static PyObject * +_curses_can_change_color_impl(PyObject *module); + +static PyObject * +_curses_can_change_color(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_can_change_color_impl(module); +} + +PyDoc_STRVAR(_curses_cbreak__doc__, +"cbreak($module, flag=True, /)\n" +"--\n" +"\n" +"Enter cbreak mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling nocbreak().\n" +"\n" +"In cbreak mode (sometimes called \"rare\" mode) normal tty line buffering is\n" +"turned off and characters are available to be read one by one. However,\n" +"unlike raw mode, special characters (interrupt, quit, suspend, and flow\n" +"control) retain their effects on the tty driver and calling program.\n" +"Calling first raw() then cbreak() leaves the terminal in cbreak mode."); + +#define _CURSES_CBREAK_METHODDEF \ + {"cbreak", (PyCFunction)(void(*)(void))_curses_cbreak, METH_FASTCALL, _curses_cbreak__doc__}, + +static PyObject * +_curses_cbreak_impl(PyObject *module, int flag); + +static PyObject * +_curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[0]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_cbreak_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_color_content__doc__, +"color_content($module, color_number, /)\n" +"--\n" +"\n" +"Return the red, green, and blue (RGB) components of the specified color.\n" +"\n" +" color_number\n" +" The number of the color (0 - (COLORS-1)).\n" +"\n" +"A 3-tuple is returned, containing the R, G, B values for the given color,\n" +"which will be between 0 (no component) and 1000 (maximum amount of component)."); + +#define _CURSES_COLOR_CONTENT_METHODDEF \ + {"color_content", (PyCFunction)_curses_color_content, METH_O, _curses_color_content__doc__}, + +static PyObject * +_curses_color_content_impl(PyObject *module, short color_number); + +static PyObject * +_curses_color_content(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short color_number; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(arg); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + color_number = (short) ival; + } + } + return_value = _curses_color_content_impl(module, color_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_color_pair__doc__, +"color_pair($module, pair_number, /)\n" +"--\n" +"\n" +"Return the attribute value for displaying text in the specified color.\n" +"\n" +" pair_number\n" +" The number of the color pair.\n" +"\n" +"This attribute value can be combined with A_STANDOUT, A_REVERSE, and the\n" +"other A_* attributes. pair_number() is the counterpart to this function."); + +#define _CURSES_COLOR_PAIR_METHODDEF \ + {"color_pair", (PyCFunction)_curses_color_pair, METH_O, _curses_color_pair__doc__}, + +static PyObject * +_curses_color_pair_impl(PyObject *module, short pair_number); + +static PyObject * +_curses_color_pair(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short pair_number; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(arg); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + pair_number = (short) ival; + } + } + return_value = _curses_color_pair_impl(module, pair_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_curs_set__doc__, +"curs_set($module, visibility, /)\n" +"--\n" +"\n" +"Set the cursor state.\n" +"\n" +" visibility\n" +" 0 for invisible, 1 for normal visible, or 2 for very visible.\n" +"\n" +"If the terminal supports the visibility requested, the previous cursor\n" +"state is returned; otherwise, an exception is raised. On many terminals,\n" +"the \"visible\" mode is an underline cursor and the \"very visible\" mode is\n" +"a block cursor."); + +#define _CURSES_CURS_SET_METHODDEF \ + {"curs_set", (PyCFunction)_curses_curs_set, METH_O, _curses_curs_set__doc__}, + +static PyObject * +_curses_curs_set_impl(PyObject *module, int visibility); + +static PyObject * +_curses_curs_set(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int visibility; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + visibility = _PyLong_AsInt(arg); + if (visibility == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_curs_set_impl(module, visibility); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_def_prog_mode__doc__, +"def_prog_mode($module, /)\n" +"--\n" +"\n" +"Save the current terminal mode as the \"program\" mode.\n" +"\n" +"The \"program\" mode is the mode when the running program is using curses.\n" +"\n" +"Subsequent calls to reset_prog_mode() will restore this mode."); + +#define _CURSES_DEF_PROG_MODE_METHODDEF \ + {"def_prog_mode", (PyCFunction)_curses_def_prog_mode, METH_NOARGS, _curses_def_prog_mode__doc__}, + +static PyObject * +_curses_def_prog_mode_impl(PyObject *module); + +static PyObject * +_curses_def_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_def_prog_mode_impl(module); +} + +PyDoc_STRVAR(_curses_def_shell_mode__doc__, +"def_shell_mode($module, /)\n" +"--\n" +"\n" +"Save the current terminal mode as the \"shell\" mode.\n" +"\n" +"The \"shell\" mode is the mode when the running program is not using curses.\n" +"\n" +"Subsequent calls to reset_shell_mode() will restore this mode."); + +#define _CURSES_DEF_SHELL_MODE_METHODDEF \ + {"def_shell_mode", (PyCFunction)_curses_def_shell_mode, METH_NOARGS, _curses_def_shell_mode__doc__}, + +static PyObject * +_curses_def_shell_mode_impl(PyObject *module); + +static PyObject * +_curses_def_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_def_shell_mode_impl(module); +} + +PyDoc_STRVAR(_curses_delay_output__doc__, +"delay_output($module, ms, /)\n" +"--\n" +"\n" +"Insert a pause in output.\n" +"\n" +" ms\n" +" Duration in milliseconds."); + +#define _CURSES_DELAY_OUTPUT_METHODDEF \ + {"delay_output", (PyCFunction)_curses_delay_output, METH_O, _curses_delay_output__doc__}, + +static PyObject * +_curses_delay_output_impl(PyObject *module, int ms); + +static PyObject * +_curses_delay_output(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int ms; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ms = _PyLong_AsInt(arg); + if (ms == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_delay_output_impl(module, ms); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_doupdate__doc__, +"doupdate($module, /)\n" +"--\n" +"\n" +"Update the physical screen to match the virtual screen."); + +#define _CURSES_DOUPDATE_METHODDEF \ + {"doupdate", (PyCFunction)_curses_doupdate, METH_NOARGS, _curses_doupdate__doc__}, + +static PyObject * +_curses_doupdate_impl(PyObject *module); + +static PyObject * +_curses_doupdate(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_doupdate_impl(module); +} + +PyDoc_STRVAR(_curses_echo__doc__, +"echo($module, flag=True, /)\n" +"--\n" +"\n" +"Enter echo mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noecho().\n" +"\n" +"In echo mode, each character input is echoed to the screen as it is entered."); + +#define _CURSES_ECHO_METHODDEF \ + {"echo", (PyCFunction)(void(*)(void))_curses_echo, METH_FASTCALL, _curses_echo__doc__}, + +static PyObject * +_curses_echo_impl(PyObject *module, int flag); + +static PyObject * +_curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[0]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_echo_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_endwin__doc__, +"endwin($module, /)\n" +"--\n" +"\n" +"De-initialize the library, and return terminal to normal status."); + +#define _CURSES_ENDWIN_METHODDEF \ + {"endwin", (PyCFunction)_curses_endwin, METH_NOARGS, _curses_endwin__doc__}, + +static PyObject * +_curses_endwin_impl(PyObject *module); + +static PyObject * +_curses_endwin(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_endwin_impl(module); +} + +PyDoc_STRVAR(_curses_erasechar__doc__, +"erasechar($module, /)\n" +"--\n" +"\n" +"Return the user\'s current erase character."); + +#define _CURSES_ERASECHAR_METHODDEF \ + {"erasechar", (PyCFunction)_curses_erasechar, METH_NOARGS, _curses_erasechar__doc__}, + +static PyObject * +_curses_erasechar_impl(PyObject *module); + +static PyObject * +_curses_erasechar(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_erasechar_impl(module); +} + +PyDoc_STRVAR(_curses_flash__doc__, +"flash($module, /)\n" +"--\n" +"\n" +"Flash the screen.\n" +"\n" +"That is, change it to reverse-video and then change it back in a short interval."); + +#define _CURSES_FLASH_METHODDEF \ + {"flash", (PyCFunction)_curses_flash, METH_NOARGS, _curses_flash__doc__}, + +static PyObject * +_curses_flash_impl(PyObject *module); + +static PyObject * +_curses_flash(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_flash_impl(module); +} + +PyDoc_STRVAR(_curses_flushinp__doc__, +"flushinp($module, /)\n" +"--\n" +"\n" +"Flush all input buffers.\n" +"\n" +"This throws away any typeahead that has been typed by the user and has not\n" +"yet been processed by the program."); + +#define _CURSES_FLUSHINP_METHODDEF \ + {"flushinp", (PyCFunction)_curses_flushinp, METH_NOARGS, _curses_flushinp__doc__}, + +static PyObject * +_curses_flushinp_impl(PyObject *module); + +static PyObject * +_curses_flushinp(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_flushinp_impl(module); +} + +#if defined(getsyx) + +PyDoc_STRVAR(_curses_getsyx__doc__, +"getsyx($module, /)\n" +"--\n" +"\n" +"Return the current coordinates of the virtual screen cursor.\n" +"\n" +"Return a (y, x) tuple. If leaveok is currently true, return (-1, -1)."); + +#define _CURSES_GETSYX_METHODDEF \ + {"getsyx", (PyCFunction)_curses_getsyx, METH_NOARGS, _curses_getsyx__doc__}, + +static PyObject * +_curses_getsyx_impl(PyObject *module); + +static PyObject * +_curses_getsyx(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_getsyx_impl(module); +} + +#endif /* defined(getsyx) */ + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_getmouse__doc__, +"getmouse($module, /)\n" +"--\n" +"\n" +"Retrieve the queued mouse event.\n" +"\n" +"After getch() returns KEY_MOUSE to signal a mouse event, this function\n" +"returns a 5-tuple (id, x, y, z, bstate)."); + +#define _CURSES_GETMOUSE_METHODDEF \ + {"getmouse", (PyCFunction)_curses_getmouse, METH_NOARGS, _curses_getmouse__doc__}, + +static PyObject * +_curses_getmouse_impl(PyObject *module); + +static PyObject * +_curses_getmouse(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_getmouse_impl(module); +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_ungetmouse__doc__, +"ungetmouse($module, id, x, y, z, bstate, /)\n" +"--\n" +"\n" +"Push a KEY_MOUSE event onto the input queue.\n" +"\n" +"The following getmouse() will return the given state data."); + +#define _CURSES_UNGETMOUSE_METHODDEF \ + {"ungetmouse", (PyCFunction)(void(*)(void))_curses_ungetmouse, METH_FASTCALL, _curses_ungetmouse__doc__}, + +static PyObject * +_curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z, + unsigned long bstate); + +static PyObject * +_curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + short id; + int x; + int y; + int z; + unsigned long bstate; + + if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[0]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + id = (short) ival; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + x = _PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + y = _PyLong_AsInt(args[2]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + z = _PyLong_AsInt(args[3]); + if (z == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyLong_Check(args[4])) { + _PyArg_BadArgument("ungetmouse", "argument 5", "int", args[4]); + goto exit; + } + bstate = PyLong_AsUnsignedLongMask(args[4]); + return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_getwin__doc__, +"getwin($module, file, /)\n" +"--\n" +"\n" +"Read window related data stored in the file by an earlier putwin() call.\n" +"\n" +"The routine then creates and initializes a new window using that data,\n" +"returning the new window object."); + +#define _CURSES_GETWIN_METHODDEF \ + {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__}, + +PyDoc_STRVAR(_curses_halfdelay__doc__, +"halfdelay($module, tenths, /)\n" +"--\n" +"\n" +"Enter half-delay mode.\n" +"\n" +" tenths\n" +" Maximal blocking delay in tenths of seconds (1 - 255).\n" +"\n" +"Use nocbreak() to leave half-delay mode."); + +#define _CURSES_HALFDELAY_METHODDEF \ + {"halfdelay", (PyCFunction)_curses_halfdelay, METH_O, _curses_halfdelay__doc__}, + +static PyObject * +_curses_halfdelay_impl(PyObject *module, unsigned char tenths); + +static PyObject * +_curses_halfdelay(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + unsigned char tenths; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(arg); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < 0) { + PyErr_SetString(PyExc_OverflowError, + "unsigned byte integer is less than minimum"); + goto exit; + } + else if (ival > UCHAR_MAX) { + PyErr_SetString(PyExc_OverflowError, + "unsigned byte integer is greater than maximum"); + goto exit; + } + else { + tenths = (unsigned char) ival; + } + } + return_value = _curses_halfdelay_impl(module, tenths); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_has_colors__doc__, +"has_colors($module, /)\n" +"--\n" +"\n" +"Return True if the terminal can display colors; otherwise, return False."); + +#define _CURSES_HAS_COLORS_METHODDEF \ + {"has_colors", (PyCFunction)_curses_has_colors, METH_NOARGS, _curses_has_colors__doc__}, + +static PyObject * +_curses_has_colors_impl(PyObject *module); + +static PyObject * +_curses_has_colors(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_colors_impl(module); +} + +PyDoc_STRVAR(_curses_has_ic__doc__, +"has_ic($module, /)\n" +"--\n" +"\n" +"Return True if the terminal has insert- and delete-character capabilities."); + +#define _CURSES_HAS_IC_METHODDEF \ + {"has_ic", (PyCFunction)_curses_has_ic, METH_NOARGS, _curses_has_ic__doc__}, + +static PyObject * +_curses_has_ic_impl(PyObject *module); + +static PyObject * +_curses_has_ic(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_ic_impl(module); +} + +PyDoc_STRVAR(_curses_has_il__doc__, +"has_il($module, /)\n" +"--\n" +"\n" +"Return True if the terminal has insert- and delete-line capabilities."); + +#define _CURSES_HAS_IL_METHODDEF \ + {"has_il", (PyCFunction)_curses_has_il, METH_NOARGS, _curses_has_il__doc__}, + +static PyObject * +_curses_has_il_impl(PyObject *module); + +static PyObject * +_curses_has_il(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_il_impl(module); +} + +#if defined(HAVE_CURSES_HAS_KEY) + +PyDoc_STRVAR(_curses_has_key__doc__, +"has_key($module, key, /)\n" +"--\n" +"\n" +"Return True if the current terminal type recognizes a key with that value.\n" +"\n" +" key\n" +" Key number."); + +#define _CURSES_HAS_KEY_METHODDEF \ + {"has_key", (PyCFunction)_curses_has_key, METH_O, _curses_has_key__doc__}, + +static PyObject * +_curses_has_key_impl(PyObject *module, int key); + +static PyObject * +_curses_has_key(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int key; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + key = _PyLong_AsInt(arg); + if (key == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_has_key_impl(module, key); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_HAS_KEY) */ + +PyDoc_STRVAR(_curses_init_color__doc__, +"init_color($module, color_number, r, g, b, /)\n" +"--\n" +"\n" +"Change the definition of a color.\n" +"\n" +" color_number\n" +" The number of the color to be changed (0 - (COLORS-1)).\n" +" r\n" +" Red component (0 - 1000).\n" +" g\n" +" Green component (0 - 1000).\n" +" b\n" +" Blue component (0 - 1000).\n" +"\n" +"When init_color() is used, all occurrences of that color on the screen\n" +"immediately change to the new definition. This function is a no-op on\n" +"most terminals; it is active only if can_change_color() returns true."); + +#define _CURSES_INIT_COLOR_METHODDEF \ + {"init_color", (PyCFunction)(void(*)(void))_curses_init_color, METH_FASTCALL, _curses_init_color__doc__}, + +static PyObject * +_curses_init_color_impl(PyObject *module, short color_number, short r, + short g, short b); + +static PyObject * +_curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + short color_number; + short r; + short g; + short b; + + if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[0]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + color_number = (short) ival; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[1]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + r = (short) ival; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[2]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + g = (short) ival; + } + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[3]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + b = (short) ival; + } + } + return_value = _curses_init_color_impl(module, color_number, r, g, b); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_init_pair__doc__, +"init_pair($module, pair_number, fg, bg, /)\n" +"--\n" +"\n" +"Change the definition of a color-pair.\n" +"\n" +" pair_number\n" +" The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).\n" +" fg\n" +" Foreground color number (-1 - (COLORS-1)).\n" +" bg\n" +" Background color number (-1 - (COLORS-1)).\n" +"\n" +"If the color-pair was previously initialized, the screen is refreshed and\n" +"all occurrences of that color-pair are changed to the new definition."); + +#define _CURSES_INIT_PAIR_METHODDEF \ + {"init_pair", (PyCFunction)(void(*)(void))_curses_init_pair, METH_FASTCALL, _curses_init_pair__doc__}, + +static PyObject * +_curses_init_pair_impl(PyObject *module, short pair_number, short fg, + short bg); + +static PyObject * +_curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + short pair_number; + short fg; + short bg; + + if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[0]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + pair_number = (short) ival; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[1]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + fg = (short) ival; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(args[2]); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + bg = (short) ival; + } + } + return_value = _curses_init_pair_impl(module, pair_number, fg, bg); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_initscr__doc__, +"initscr($module, /)\n" +"--\n" +"\n" +"Initialize the library.\n" +"\n" +"Return a WindowObject which represents the whole screen."); + +#define _CURSES_INITSCR_METHODDEF \ + {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__}, + +static PyObject * +_curses_initscr_impl(PyObject *module); + +static PyObject * +_curses_initscr(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_initscr_impl(module); +} + +PyDoc_STRVAR(_curses_setupterm__doc__, +"setupterm($module, /, term=None, fd=-1)\n" +"--\n" +"\n" +"Initialize the terminal.\n" +"\n" +" term\n" +" Terminal name.\n" +" If omitted, the value of the TERM environment variable will be used.\n" +" fd\n" +" File descriptor to which any initialization sequences will be sent.\n" +" If not supplied, the file descriptor for sys.stdout will be used."); + +#define _CURSES_SETUPTERM_METHODDEF \ + {"setupterm", (PyCFunction)(void(*)(void))_curses_setupterm, METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__}, + +static PyObject * +_curses_setupterm_impl(PyObject *module, const char *term, int fd); + +static PyObject * +_curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"term", "fd", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "setupterm", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + const char *term = NULL; + int fd = -1; + + 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]) { + if (args[0] == Py_None) { + term = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t term_length; + term = PyUnicode_AsUTF8AndSize(args[0], &term_length); + if (term == NULL) { + goto exit; + } + if (strlen(term) != (size_t)term_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("setupterm", "argument 'term'", "str or None", args[0]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[1]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _curses_setupterm_impl(module, term, fd); + +exit: + return return_value; +} + +#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) + +PyDoc_STRVAR(_curses_get_escdelay__doc__, +"get_escdelay($module, /)\n" +"--\n" +"\n" +"Gets the curses ESCDELAY setting.\n" +"\n" +"Gets the number of milliseconds to wait after reading an escape character,\n" +"to distinguish between an individual escape character entered on the\n" +"keyboard from escape sequences sent by cursor and function keys."); + +#define _CURSES_GET_ESCDELAY_METHODDEF \ + {"get_escdelay", (PyCFunction)_curses_get_escdelay, METH_NOARGS, _curses_get_escdelay__doc__}, + +static PyObject * +_curses_get_escdelay_impl(PyObject *module); + +static PyObject * +_curses_get_escdelay(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_get_escdelay_impl(module); +} + +#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ + +#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) + +PyDoc_STRVAR(_curses_set_escdelay__doc__, +"set_escdelay($module, ms, /)\n" +"--\n" +"\n" +"Sets the curses ESCDELAY setting.\n" +"\n" +" ms\n" +" length of the delay in milliseconds.\n" +"\n" +"Sets the number of milliseconds to wait after reading an escape character,\n" +"to distinguish between an individual escape character entered on the\n" +"keyboard from escape sequences sent by cursor and function keys."); + +#define _CURSES_SET_ESCDELAY_METHODDEF \ + {"set_escdelay", (PyCFunction)_curses_set_escdelay, METH_O, _curses_set_escdelay__doc__}, + +static PyObject * +_curses_set_escdelay_impl(PyObject *module, int ms); + +static PyObject * +_curses_set_escdelay(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int ms; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ms = _PyLong_AsInt(arg); + if (ms == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_set_escdelay_impl(module, ms); + +exit: + return return_value; +} + +#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ + +#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) + +PyDoc_STRVAR(_curses_get_tabsize__doc__, +"get_tabsize($module, /)\n" +"--\n" +"\n" +"Gets the curses TABSIZE setting.\n" +"\n" +"Gets the number of columns used by the curses library when converting a tab\n" +"character to spaces as it adds the tab to a window."); + +#define _CURSES_GET_TABSIZE_METHODDEF \ + {"get_tabsize", (PyCFunction)_curses_get_tabsize, METH_NOARGS, _curses_get_tabsize__doc__}, + +static PyObject * +_curses_get_tabsize_impl(PyObject *module); + +static PyObject * +_curses_get_tabsize(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_get_tabsize_impl(module); +} + +#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ + +#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) + +PyDoc_STRVAR(_curses_set_tabsize__doc__, +"set_tabsize($module, size, /)\n" +"--\n" +"\n" +"Sets the curses TABSIZE setting.\n" +"\n" +" size\n" +" rendered cell width of a tab character.\n" +"\n" +"Sets the number of columns used by the curses library when converting a tab\n" +"character to spaces as it adds the tab to a window."); + +#define _CURSES_SET_TABSIZE_METHODDEF \ + {"set_tabsize", (PyCFunction)_curses_set_tabsize, METH_O, _curses_set_tabsize__doc__}, + +static PyObject * +_curses_set_tabsize_impl(PyObject *module, int size); + +static PyObject * +_curses_set_tabsize(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int size; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + size = _PyLong_AsInt(arg); + if (size == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_set_tabsize_impl(module, size); + +exit: + return return_value; +} + +#endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */ + +PyDoc_STRVAR(_curses_intrflush__doc__, +"intrflush($module, flag, /)\n" +"--\n" +"\n"); + +#define _CURSES_INTRFLUSH_METHODDEF \ + {"intrflush", (PyCFunction)_curses_intrflush, METH_O, _curses_intrflush__doc__}, + +static PyObject * +_curses_intrflush_impl(PyObject *module, int flag); + +static PyObject * +_curses_intrflush(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int flag; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(arg); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_intrflush_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_isendwin__doc__, +"isendwin($module, /)\n" +"--\n" +"\n" +"Return True if endwin() has been called."); + +#define _CURSES_ISENDWIN_METHODDEF \ + {"isendwin", (PyCFunction)_curses_isendwin, METH_NOARGS, _curses_isendwin__doc__}, + +static PyObject * +_curses_isendwin_impl(PyObject *module); + +static PyObject * +_curses_isendwin(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_isendwin_impl(module); +} + +#if defined(HAVE_CURSES_IS_TERM_RESIZED) + +PyDoc_STRVAR(_curses_is_term_resized__doc__, +"is_term_resized($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Return True if resize_term() would modify the window structure, False otherwise.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width."); + +#define _CURSES_IS_TERM_RESIZED_METHODDEF \ + {"is_term_resized", (PyCFunction)(void(*)(void))_curses_is_term_resized, METH_FASTCALL, _curses_is_term_resized__doc__}, + +static PyObject * +_curses_is_term_resized_impl(PyObject *module, int nlines, int ncols); + +static PyObject * +_curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nlines = _PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ncols = _PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_is_term_resized_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_IS_TERM_RESIZED) */ + +PyDoc_STRVAR(_curses_keyname__doc__, +"keyname($module, key, /)\n" +"--\n" +"\n" +"Return the name of specified key.\n" +"\n" +" key\n" +" Key number."); + +#define _CURSES_KEYNAME_METHODDEF \ + {"keyname", (PyCFunction)_curses_keyname, METH_O, _curses_keyname__doc__}, + +static PyObject * +_curses_keyname_impl(PyObject *module, int key); + +static PyObject * +_curses_keyname(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int key; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + key = _PyLong_AsInt(arg); + if (key == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_keyname_impl(module, key); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_killchar__doc__, +"killchar($module, /)\n" +"--\n" +"\n" +"Return the user\'s current line kill character."); + +#define _CURSES_KILLCHAR_METHODDEF \ + {"killchar", (PyCFunction)_curses_killchar, METH_NOARGS, _curses_killchar__doc__}, + +static PyObject * +_curses_killchar_impl(PyObject *module); + +static PyObject * +_curses_killchar(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_killchar_impl(module); +} + +PyDoc_STRVAR(_curses_longname__doc__, +"longname($module, /)\n" +"--\n" +"\n" +"Return the terminfo long name field describing the current terminal.\n" +"\n" +"The maximum length of a verbose description is 128 characters. It is defined\n" +"only after the call to initscr()."); + +#define _CURSES_LONGNAME_METHODDEF \ + {"longname", (PyCFunction)_curses_longname, METH_NOARGS, _curses_longname__doc__}, + +static PyObject * +_curses_longname_impl(PyObject *module); + +static PyObject * +_curses_longname(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_longname_impl(module); +} + +PyDoc_STRVAR(_curses_meta__doc__, +"meta($module, yes, /)\n" +"--\n" +"\n" +"Enable/disable meta keys.\n" +"\n" +"If yes is True, allow 8-bit characters to be input. If yes is False,\n" +"allow only 7-bit characters."); + +#define _CURSES_META_METHODDEF \ + {"meta", (PyCFunction)_curses_meta, METH_O, _curses_meta__doc__}, + +static PyObject * +_curses_meta_impl(PyObject *module, int yes); + +static PyObject * +_curses_meta(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int yes; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + yes = _PyLong_AsInt(arg); + if (yes == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_meta_impl(module, yes); + +exit: + return return_value; +} + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_mouseinterval__doc__, +"mouseinterval($module, interval, /)\n" +"--\n" +"\n" +"Set and retrieve the maximum time between press and release in a click.\n" +"\n" +" interval\n" +" Time in milliseconds.\n" +"\n" +"Set the maximum time that can elapse between press and release events in\n" +"order for them to be recognized as a click, and return the previous interval\n" +"value."); + +#define _CURSES_MOUSEINTERVAL_METHODDEF \ + {"mouseinterval", (PyCFunction)_curses_mouseinterval, METH_O, _curses_mouseinterval__doc__}, + +static PyObject * +_curses_mouseinterval_impl(PyObject *module, int interval); + +static PyObject * +_curses_mouseinterval(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int interval; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + interval = _PyLong_AsInt(arg); + if (interval == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_mouseinterval_impl(module, interval); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_mousemask__doc__, +"mousemask($module, newmask, /)\n" +"--\n" +"\n" +"Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n" +"\n" +"Return a tuple (availmask, oldmask). availmask indicates which of the\n" +"specified mouse events can be reported; on complete failure it returns 0.\n" +"oldmask is the previous value of the given window\'s mouse event mask.\n" +"If this function is never called, no mouse events are ever reported."); + +#define _CURSES_MOUSEMASK_METHODDEF \ + {"mousemask", (PyCFunction)_curses_mousemask, METH_O, _curses_mousemask__doc__}, + +static PyObject * +_curses_mousemask_impl(PyObject *module, unsigned long newmask); + +static PyObject * +_curses_mousemask(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + unsigned long newmask; + + if (!PyLong_Check(arg)) { + _PyArg_BadArgument("mousemask", "argument", "int", arg); + goto exit; + } + newmask = PyLong_AsUnsignedLongMask(arg); + return_value = _curses_mousemask_impl(module, newmask); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_napms__doc__, +"napms($module, ms, /)\n" +"--\n" +"\n" +"Sleep for specified time.\n" +"\n" +" ms\n" +" Duration in milliseconds."); + +#define _CURSES_NAPMS_METHODDEF \ + {"napms", (PyCFunction)_curses_napms, METH_O, _curses_napms__doc__}, + +static PyObject * +_curses_napms_impl(PyObject *module, int ms); + +static PyObject * +_curses_napms(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int ms; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ms = _PyLong_AsInt(arg); + if (ms == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_napms_impl(module, ms); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_newpad__doc__, +"newpad($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Create and return a pointer to a new pad data structure.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width."); + +#define _CURSES_NEWPAD_METHODDEF \ + {"newpad", (PyCFunction)(void(*)(void))_curses_newpad, METH_FASTCALL, _curses_newpad__doc__}, + +static PyObject * +_curses_newpad_impl(PyObject *module, int nlines, int ncols); + +static PyObject * +_curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nlines = _PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ncols = _PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_newpad_impl(module, nlines, ncols); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_newwin__doc__, +"newwin(nlines, ncols, [begin_y=0, begin_x=0])\n" +"Return a new window.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"By default, the window will extend from the specified position to the lower\n" +"right corner of the screen."); + +#define _CURSES_NEWWIN_METHODDEF \ + {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__}, + +static PyObject * +_curses_newwin_impl(PyObject *module, int nlines, int ncols, + int group_right_1, int begin_y, int begin_x); + +static PyObject * +_curses_newwin(PyObject *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + int group_right_1 = 0; + int begin_y = 0; + int begin_x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) { + goto exit; + } + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_nl__doc__, +"nl($module, flag=True, /)\n" +"--\n" +"\n" +"Enter newline mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling nonl().\n" +"\n" +"This mode translates the return key into newline on input, and translates\n" +"newline into return and line-feed on output. Newline mode is initially on."); + +#define _CURSES_NL_METHODDEF \ + {"nl", (PyCFunction)(void(*)(void))_curses_nl, METH_FASTCALL, _curses_nl__doc__}, + +static PyObject * +_curses_nl_impl(PyObject *module, int flag); + +static PyObject * +_curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[0]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_nl_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_nocbreak__doc__, +"nocbreak($module, /)\n" +"--\n" +"\n" +"Leave cbreak mode.\n" +"\n" +"Return to normal \"cooked\" mode with line buffering."); + +#define _CURSES_NOCBREAK_METHODDEF \ + {"nocbreak", (PyCFunction)_curses_nocbreak, METH_NOARGS, _curses_nocbreak__doc__}, + +static PyObject * +_curses_nocbreak_impl(PyObject *module); + +static PyObject * +_curses_nocbreak(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_nocbreak_impl(module); +} + +PyDoc_STRVAR(_curses_noecho__doc__, +"noecho($module, /)\n" +"--\n" +"\n" +"Leave echo mode.\n" +"\n" +"Echoing of input characters is turned off."); + +#define _CURSES_NOECHO_METHODDEF \ + {"noecho", (PyCFunction)_curses_noecho, METH_NOARGS, _curses_noecho__doc__}, + +static PyObject * +_curses_noecho_impl(PyObject *module); + +static PyObject * +_curses_noecho(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noecho_impl(module); +} + +PyDoc_STRVAR(_curses_nonl__doc__, +"nonl($module, /)\n" +"--\n" +"\n" +"Leave newline mode.\n" +"\n" +"Disable translation of return into newline on input, and disable low-level\n" +"translation of newline into newline/return on output."); + +#define _CURSES_NONL_METHODDEF \ + {"nonl", (PyCFunction)_curses_nonl, METH_NOARGS, _curses_nonl__doc__}, + +static PyObject * +_curses_nonl_impl(PyObject *module); + +static PyObject * +_curses_nonl(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_nonl_impl(module); +} + +PyDoc_STRVAR(_curses_noqiflush__doc__, +"noqiflush($module, /)\n" +"--\n" +"\n" +"Disable queue flushing.\n" +"\n" +"When queue flushing is disabled, normal flush of input and output queues\n" +"associated with the INTR, QUIT and SUSP characters will not be done."); + +#define _CURSES_NOQIFLUSH_METHODDEF \ + {"noqiflush", (PyCFunction)_curses_noqiflush, METH_NOARGS, _curses_noqiflush__doc__}, + +static PyObject * +_curses_noqiflush_impl(PyObject *module); + +static PyObject * +_curses_noqiflush(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noqiflush_impl(module); +} + +PyDoc_STRVAR(_curses_noraw__doc__, +"noraw($module, /)\n" +"--\n" +"\n" +"Leave raw mode.\n" +"\n" +"Return to normal \"cooked\" mode with line buffering."); + +#define _CURSES_NORAW_METHODDEF \ + {"noraw", (PyCFunction)_curses_noraw, METH_NOARGS, _curses_noraw__doc__}, + +static PyObject * +_curses_noraw_impl(PyObject *module); + +static PyObject * +_curses_noraw(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noraw_impl(module); +} + +PyDoc_STRVAR(_curses_pair_content__doc__, +"pair_content($module, pair_number, /)\n" +"--\n" +"\n" +"Return a tuple (fg, bg) containing the colors for the requested color pair.\n" +"\n" +" pair_number\n" +" The number of the color pair (1 - (COLOR_PAIRS-1))."); + +#define _CURSES_PAIR_CONTENT_METHODDEF \ + {"pair_content", (PyCFunction)_curses_pair_content, METH_O, _curses_pair_content__doc__}, + +static PyObject * +_curses_pair_content_impl(PyObject *module, short pair_number); + +static PyObject * +_curses_pair_content(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short pair_number; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + long ival = PyLong_AsLong(arg); + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is less than minimum"); + goto exit; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "signed short integer is greater than maximum"); + goto exit; + } + else { + pair_number = (short) ival; + } + } + return_value = _curses_pair_content_impl(module, pair_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_pair_number__doc__, +"pair_number($module, attr, /)\n" +"--\n" +"\n" +"Return the number of the color-pair set by the specified attribute value.\n" +"\n" +"color_pair() is the counterpart to this function."); + +#define _CURSES_PAIR_NUMBER_METHODDEF \ + {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__}, + +static PyObject * +_curses_pair_number_impl(PyObject *module, int attr); + +static PyObject * +_curses_pair_number(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int attr; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + attr = _PyLong_AsInt(arg); + if (attr == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_pair_number_impl(module, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_putp__doc__, +"putp($module, string, /)\n" +"--\n" +"\n" +"Emit the value of a specified terminfo capability for the current terminal.\n" +"\n" +"Note that the output of putp() always goes to standard output."); + +#define _CURSES_PUTP_METHODDEF \ + {"putp", (PyCFunction)_curses_putp, METH_O, _curses_putp__doc__}, + +static PyObject * +_curses_putp_impl(PyObject *module, const char *string); + +static PyObject * +_curses_putp(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *string; + + if (!PyArg_Parse(arg, "y:putp", &string)) { + goto exit; + } + return_value = _curses_putp_impl(module, string); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_qiflush__doc__, +"qiflush($module, flag=True, /)\n" +"--\n" +"\n" +"Enable queue flushing.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noqiflush().\n" +"\n" +"If queue flushing is enabled, all output in the display driver queue\n" +"will be flushed when the INTR, QUIT and SUSP characters are read."); + +#define _CURSES_QIFLUSH_METHODDEF \ + {"qiflush", (PyCFunction)(void(*)(void))_curses_qiflush, METH_FASTCALL, _curses_qiflush__doc__}, + +static PyObject * +_curses_qiflush_impl(PyObject *module, int flag); + +static PyObject * +_curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[0]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_qiflush_impl(module, flag); + +exit: + return return_value; +} + +#if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) + +PyDoc_STRVAR(_curses_update_lines_cols__doc__, +"update_lines_cols($module, /)\n" +"--\n" +"\n"); + +#define _CURSES_UPDATE_LINES_COLS_METHODDEF \ + {"update_lines_cols", (PyCFunction)_curses_update_lines_cols, METH_NOARGS, _curses_update_lines_cols__doc__}, + +static PyObject * +_curses_update_lines_cols_impl(PyObject *module); + +static PyObject * +_curses_update_lines_cols(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_update_lines_cols_impl(module); +} + +#endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */ + +PyDoc_STRVAR(_curses_raw__doc__, +"raw($module, flag=True, /)\n" +"--\n" +"\n" +"Enter raw mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noraw().\n" +"\n" +"In raw mode, normal line buffering and processing of interrupt, quit,\n" +"suspend, and flow control keys are turned off; characters are presented to\n" +"curses input functions one by one."); + +#define _CURSES_RAW_METHODDEF \ + {"raw", (PyCFunction)(void(*)(void))_curses_raw, METH_FASTCALL, _curses_raw__doc__}, + +static PyObject * +_curses_raw_impl(PyObject *module, int flag); + +static PyObject * +_curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[0]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _curses_raw_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_reset_prog_mode__doc__, +"reset_prog_mode($module, /)\n" +"--\n" +"\n" +"Restore the terminal to \"program\" mode, as previously saved by def_prog_mode()."); + +#define _CURSES_RESET_PROG_MODE_METHODDEF \ + {"reset_prog_mode", (PyCFunction)_curses_reset_prog_mode, METH_NOARGS, _curses_reset_prog_mode__doc__}, + +static PyObject * +_curses_reset_prog_mode_impl(PyObject *module); + +static PyObject * +_curses_reset_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_reset_prog_mode_impl(module); +} + +PyDoc_STRVAR(_curses_reset_shell_mode__doc__, +"reset_shell_mode($module, /)\n" +"--\n" +"\n" +"Restore the terminal to \"shell\" mode, as previously saved by def_shell_mode()."); + +#define _CURSES_RESET_SHELL_MODE_METHODDEF \ + {"reset_shell_mode", (PyCFunction)_curses_reset_shell_mode, METH_NOARGS, _curses_reset_shell_mode__doc__}, + +static PyObject * +_curses_reset_shell_mode_impl(PyObject *module); + +static PyObject * +_curses_reset_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_reset_shell_mode_impl(module); +} + +PyDoc_STRVAR(_curses_resetty__doc__, +"resetty($module, /)\n" +"--\n" +"\n" +"Restore terminal mode."); + +#define _CURSES_RESETTY_METHODDEF \ + {"resetty", (PyCFunction)_curses_resetty, METH_NOARGS, _curses_resetty__doc__}, + +static PyObject * +_curses_resetty_impl(PyObject *module); + +static PyObject * +_curses_resetty(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_resetty_impl(module); +} + +#if defined(HAVE_CURSES_RESIZETERM) + +PyDoc_STRVAR(_curses_resizeterm__doc__, +"resizeterm($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Resize the standard and current windows to the specified dimensions.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +"\n" +"Adjusts other bookkeeping data used by the curses library that record the\n" +"window dimensions (in particular the SIGWINCH handler)."); + +#define _CURSES_RESIZETERM_METHODDEF \ + {"resizeterm", (PyCFunction)(void(*)(void))_curses_resizeterm, METH_FASTCALL, _curses_resizeterm__doc__}, + +static PyObject * +_curses_resizeterm_impl(PyObject *module, int nlines, int ncols); + +static PyObject * +_curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nlines = _PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ncols = _PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_resizeterm_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_RESIZETERM) */ + +#if defined(HAVE_CURSES_RESIZE_TERM) + +PyDoc_STRVAR(_curses_resize_term__doc__, +"resize_term($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Backend function used by resizeterm(), performing most of the work.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +"\n" +"When resizing the windows, resize_term() blank-fills the areas that are\n" +"extended. The calling application should fill in these areas with appropriate\n" +"data. The resize_term() function attempts to resize all windows. However,\n" +"due to the calling convention of pads, it is not possible to resize these\n" +"without additional interaction with the application."); + +#define _CURSES_RESIZE_TERM_METHODDEF \ + {"resize_term", (PyCFunction)(void(*)(void))_curses_resize_term, METH_FASTCALL, _curses_resize_term__doc__}, + +static PyObject * +_curses_resize_term_impl(PyObject *module, int nlines, int ncols); + +static PyObject * +_curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nlines = _PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + ncols = _PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_resize_term_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_RESIZE_TERM) */ + +PyDoc_STRVAR(_curses_savetty__doc__, +"savetty($module, /)\n" +"--\n" +"\n" +"Save terminal mode."); + +#define _CURSES_SAVETTY_METHODDEF \ + {"savetty", (PyCFunction)_curses_savetty, METH_NOARGS, _curses_savetty__doc__}, + +static PyObject * +_curses_savetty_impl(PyObject *module); + +static PyObject * +_curses_savetty(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_savetty_impl(module); +} + +#if defined(getsyx) + +PyDoc_STRVAR(_curses_setsyx__doc__, +"setsyx($module, y, x, /)\n" +"--\n" +"\n" +"Set the virtual screen cursor.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"If y and x are both -1, then leaveok is set."); + +#define _CURSES_SETSYX_METHODDEF \ + {"setsyx", (PyCFunction)(void(*)(void))_curses_setsyx, METH_FASTCALL, _curses_setsyx__doc__}, + +static PyObject * +_curses_setsyx_impl(PyObject *module, int y, int x); + +static PyObject * +_curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int y; + int x; + + if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + y = _PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + x = _PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_setsyx_impl(module, y, x); + +exit: + return return_value; +} + +#endif /* defined(getsyx) */ + +PyDoc_STRVAR(_curses_start_color__doc__, +"start_color($module, /)\n" +"--\n" +"\n" +"Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.\n" +"\n" +"Must be called if the programmer wants to use colors, and before any other\n" +"color manipulation routine is called. It is good practice to call this\n" +"routine right after initscr().\n" +"\n" +"It also restores the colors on the terminal to the values they had when the\n" +"terminal was just turned on."); + +#define _CURSES_START_COLOR_METHODDEF \ + {"start_color", (PyCFunction)_curses_start_color, METH_NOARGS, _curses_start_color__doc__}, + +static PyObject * +_curses_start_color_impl(PyObject *module); + +static PyObject * +_curses_start_color(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_start_color_impl(module); +} + +PyDoc_STRVAR(_curses_termattrs__doc__, +"termattrs($module, /)\n" +"--\n" +"\n" +"Return a logical OR of all video attributes supported by the terminal."); + +#define _CURSES_TERMATTRS_METHODDEF \ + {"termattrs", (PyCFunction)_curses_termattrs, METH_NOARGS, _curses_termattrs__doc__}, + +static PyObject * +_curses_termattrs_impl(PyObject *module); + +static PyObject * +_curses_termattrs(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_termattrs_impl(module); +} + +PyDoc_STRVAR(_curses_termname__doc__, +"termname($module, /)\n" +"--\n" +"\n" +"Return the value of the environment variable TERM, truncated to 14 characters."); + +#define _CURSES_TERMNAME_METHODDEF \ + {"termname", (PyCFunction)_curses_termname, METH_NOARGS, _curses_termname__doc__}, + +static PyObject * +_curses_termname_impl(PyObject *module); + +static PyObject * +_curses_termname(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_termname_impl(module); +} + +PyDoc_STRVAR(_curses_tigetflag__doc__, +"tigetflag($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the Boolean capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"The value -1 is returned if capname is not a Boolean capability, or 0 if\n" +"it is canceled or absent from the terminal description."); + +#define _CURSES_TIGETFLAG_METHODDEF \ + {"tigetflag", (PyCFunction)_curses_tigetflag, METH_O, _curses_tigetflag__doc__}, + +static PyObject * +_curses_tigetflag_impl(PyObject *module, const char *capname); + +static PyObject * +_curses_tigetflag(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("tigetflag", "argument", "str", arg); + goto exit; + } + Py_ssize_t capname_length; + capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + if (capname == NULL) { + goto exit; + } + if (strlen(capname) != (size_t)capname_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = _curses_tigetflag_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tigetnum__doc__, +"tigetnum($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the numeric capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"The value -2 is returned if capname is not a numeric capability, or -1 if\n" +"it is canceled or absent from the terminal description."); + +#define _CURSES_TIGETNUM_METHODDEF \ + {"tigetnum", (PyCFunction)_curses_tigetnum, METH_O, _curses_tigetnum__doc__}, + +static PyObject * +_curses_tigetnum_impl(PyObject *module, const char *capname); + +static PyObject * +_curses_tigetnum(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("tigetnum", "argument", "str", arg); + goto exit; + } + Py_ssize_t capname_length; + capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + if (capname == NULL) { + goto exit; + } + if (strlen(capname) != (size_t)capname_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = _curses_tigetnum_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tigetstr__doc__, +"tigetstr($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the string capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"None is returned if capname is not a string capability, or is canceled or\n" +"absent from the terminal description."); + +#define _CURSES_TIGETSTR_METHODDEF \ + {"tigetstr", (PyCFunction)_curses_tigetstr, METH_O, _curses_tigetstr__doc__}, + +static PyObject * +_curses_tigetstr_impl(PyObject *module, const char *capname); + +static PyObject * +_curses_tigetstr(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("tigetstr", "argument", "str", arg); + goto exit; + } + Py_ssize_t capname_length; + capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + if (capname == NULL) { + goto exit; + } + if (strlen(capname) != (size_t)capname_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = _curses_tigetstr_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tparm__doc__, +"tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n" +" i9=0, /)\n" +"--\n" +"\n" +"Instantiate the specified byte string with the supplied parameters.\n" +"\n" +" str\n" +" Parameterized byte string obtained from the terminfo database."); + +#define _CURSES_TPARM_METHODDEF \ + {"tparm", (PyCFunction)(void(*)(void))_curses_tparm, METH_FASTCALL, _curses_tparm__doc__}, + +static PyObject * +_curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, + int i4, int i5, int i6, int i7, int i8, int i9); + +static PyObject * +_curses_tparm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + const char *str; + int i1 = 0; + int i2 = 0; + int i3 = 0; + int i4 = 0; + int i5 = 0; + int i6 = 0; + int i7 = 0; + int i8 = 0; + int i9 = 0; + + if (!_PyArg_ParseStack(args, nargs, "y|iiiiiiiii:tparm", + &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) { + goto exit; + } + return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9); + +exit: + return return_value; +} + +#if defined(HAVE_CURSES_TYPEAHEAD) + +PyDoc_STRVAR(_curses_typeahead__doc__, +"typeahead($module, fd, /)\n" +"--\n" +"\n" +"Specify that the file descriptor fd be used for typeahead checking.\n" +"\n" +" fd\n" +" File descriptor.\n" +"\n" +"If fd is -1, then no typeahead checking is done."); + +#define _CURSES_TYPEAHEAD_METHODDEF \ + {"typeahead", (PyCFunction)_curses_typeahead, METH_O, _curses_typeahead__doc__}, + +static PyObject * +_curses_typeahead_impl(PyObject *module, int fd); + +static PyObject * +_curses_typeahead(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_typeahead_impl(module, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_TYPEAHEAD) */ + +PyDoc_STRVAR(_curses_unctrl__doc__, +"unctrl($module, ch, /)\n" +"--\n" +"\n" +"Return a string which is a printable representation of the character ch.\n" +"\n" +"Control characters are displayed as a caret followed by the character,\n" +"for example as ^C. Printing characters are left as they are."); + +#define _CURSES_UNCTRL_METHODDEF \ + {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__}, + +PyDoc_STRVAR(_curses_ungetch__doc__, +"ungetch($module, ch, /)\n" +"--\n" +"\n" +"Push ch so the next getch() will return it."); + +#define _CURSES_UNGETCH_METHODDEF \ + {"ungetch", (PyCFunction)_curses_ungetch, METH_O, _curses_ungetch__doc__}, + +#if defined(HAVE_NCURSESW) + +PyDoc_STRVAR(_curses_unget_wch__doc__, +"unget_wch($module, ch, /)\n" +"--\n" +"\n" +"Push ch so the next get_wch() will return it."); + +#define _CURSES_UNGET_WCH_METHODDEF \ + {"unget_wch", (PyCFunction)_curses_unget_wch, METH_O, _curses_unget_wch__doc__}, + +#endif /* defined(HAVE_NCURSESW) */ + +#if defined(HAVE_CURSES_USE_ENV) + +PyDoc_STRVAR(_curses_use_env__doc__, +"use_env($module, flag, /)\n" +"--\n" +"\n" +"Use environment variables LINES and COLUMNS.\n" +"\n" +"If used, this function should be called before initscr() or newterm() are\n" +"called.\n" +"\n" +"When flag is False, the values of lines and columns specified in the terminfo\n" +"database will be used, even if environment variables LINES and COLUMNS (used\n" +"by default) are set, or if curses is running in a window (in which case\n" +"default behavior would be to use the window size if LINES and COLUMNS are\n" +"not set)."); + +#define _CURSES_USE_ENV_METHODDEF \ + {"use_env", (PyCFunction)_curses_use_env, METH_O, _curses_use_env__doc__}, + +static PyObject * +_curses_use_env_impl(PyObject *module, int flag); + +static PyObject * +_curses_use_env(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int flag; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(arg); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _curses_use_env_impl(module, flag); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_USE_ENV) */ + +#if !defined(STRICT_SYSV_CURSES) + +PyDoc_STRVAR(_curses_use_default_colors__doc__, +"use_default_colors($module, /)\n" +"--\n" +"\n" +"Allow use of default values for colors on terminals supporting this feature.\n" +"\n" +"Use this to support transparency in your application. The default color\n" +"is assigned to the color number -1."); + +#define _CURSES_USE_DEFAULT_COLORS_METHODDEF \ + {"use_default_colors", (PyCFunction)_curses_use_default_colors, METH_NOARGS, _curses_use_default_colors__doc__}, + +static PyObject * +_curses_use_default_colors_impl(PyObject *module); + +static PyObject * +_curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_use_default_colors_impl(module); +} + +#endif /* !defined(STRICT_SYSV_CURSES) */ + +#ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF + #define _CURSES_WINDOW_ENCLOSE_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */ + +#ifndef _CURSES_WINDOW_GET_WCH_METHODDEF + #define _CURSES_WINDOW_GET_WCH_METHODDEF +#endif /* !defined(_CURSES_WINDOW_GET_WCH_METHODDEF) */ + +#ifndef _CURSES_WINDOW_NOUTREFRESH_METHODDEF + #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF +#endif /* !defined(_CURSES_WINDOW_NOUTREFRESH_METHODDEF) */ + +#ifndef _CURSES_FILTER_METHODDEF + #define _CURSES_FILTER_METHODDEF +#endif /* !defined(_CURSES_FILTER_METHODDEF) */ + +#ifndef _CURSES_GETSYX_METHODDEF + #define _CURSES_GETSYX_METHODDEF +#endif /* !defined(_CURSES_GETSYX_METHODDEF) */ + +#ifndef _CURSES_GETMOUSE_METHODDEF + #define _CURSES_GETMOUSE_METHODDEF +#endif /* !defined(_CURSES_GETMOUSE_METHODDEF) */ + +#ifndef _CURSES_UNGETMOUSE_METHODDEF + #define _CURSES_UNGETMOUSE_METHODDEF +#endif /* !defined(_CURSES_UNGETMOUSE_METHODDEF) */ + +#ifndef _CURSES_HAS_KEY_METHODDEF + #define _CURSES_HAS_KEY_METHODDEF +#endif /* !defined(_CURSES_HAS_KEY_METHODDEF) */ + +#ifndef _CURSES_GET_ESCDELAY_METHODDEF + #define _CURSES_GET_ESCDELAY_METHODDEF +#endif /* !defined(_CURSES_GET_ESCDELAY_METHODDEF) */ + +#ifndef _CURSES_SET_ESCDELAY_METHODDEF + #define _CURSES_SET_ESCDELAY_METHODDEF +#endif /* !defined(_CURSES_SET_ESCDELAY_METHODDEF) */ + +#ifndef _CURSES_GET_TABSIZE_METHODDEF + #define _CURSES_GET_TABSIZE_METHODDEF +#endif /* !defined(_CURSES_GET_TABSIZE_METHODDEF) */ + +#ifndef _CURSES_SET_TABSIZE_METHODDEF + #define _CURSES_SET_TABSIZE_METHODDEF +#endif /* !defined(_CURSES_SET_TABSIZE_METHODDEF) */ + +#ifndef _CURSES_IS_TERM_RESIZED_METHODDEF + #define _CURSES_IS_TERM_RESIZED_METHODDEF +#endif /* !defined(_CURSES_IS_TERM_RESIZED_METHODDEF) */ + +#ifndef _CURSES_MOUSEINTERVAL_METHODDEF + #define _CURSES_MOUSEINTERVAL_METHODDEF +#endif /* !defined(_CURSES_MOUSEINTERVAL_METHODDEF) */ + +#ifndef _CURSES_MOUSEMASK_METHODDEF + #define _CURSES_MOUSEMASK_METHODDEF +#endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */ + +#ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF + #define _CURSES_UPDATE_LINES_COLS_METHODDEF +#endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */ + +#ifndef _CURSES_RESIZETERM_METHODDEF + #define _CURSES_RESIZETERM_METHODDEF +#endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */ + +#ifndef _CURSES_RESIZE_TERM_METHODDEF + #define _CURSES_RESIZE_TERM_METHODDEF +#endif /* !defined(_CURSES_RESIZE_TERM_METHODDEF) */ + +#ifndef _CURSES_SETSYX_METHODDEF + #define _CURSES_SETSYX_METHODDEF +#endif /* !defined(_CURSES_SETSYX_METHODDEF) */ + +#ifndef _CURSES_TYPEAHEAD_METHODDEF + #define _CURSES_TYPEAHEAD_METHODDEF +#endif /* !defined(_CURSES_TYPEAHEAD_METHODDEF) */ + +#ifndef _CURSES_UNGET_WCH_METHODDEF + #define _CURSES_UNGET_WCH_METHODDEF +#endif /* !defined(_CURSES_UNGET_WCH_METHODDEF) */ + +#ifndef _CURSES_USE_ENV_METHODDEF + #define _CURSES_USE_ENV_METHODDEF +#endif /* !defined(_CURSES_USE_ENV_METHODDEF) */ + +#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF + #define _CURSES_USE_DEFAULT_COLORS_METHODDEF +#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */ +/*[clinic end generated code: output=5e739120041df368 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_datetimemodule.c.h b/contrib/tools/python3/src/Modules/clinic/_datetimemodule.c.h index 973a4ea025..f11a3a2e47 100644 --- a/contrib/tools/python3/src/Modules/clinic/_datetimemodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_datetimemodule.c.h @@ -2,72 +2,72 @@ preserve [clinic start generated code]*/ -PyDoc_STRVAR(datetime_date_fromtimestamp__doc__, -"fromtimestamp($type, timestamp, /)\n" -"--\n" -"\n" -"Create a date from a POSIX timestamp.\n" -"\n" -"The timestamp is a number, e.g. created via time.time(), that is interpreted\n" -"as local time."); - -#define DATETIME_DATE_FROMTIMESTAMP_METHODDEF \ - {"fromtimestamp", (PyCFunction)datetime_date_fromtimestamp, METH_O|METH_CLASS, datetime_date_fromtimestamp__doc__}, - -static PyObject * -iso_calendar_date_new_impl(PyTypeObject *type, int year, int week, - int weekday); - -static PyObject * -iso_calendar_date_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"year", "week", "weekday", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "IsoCalendarDate", 0}; - PyObject *argsbuf[3]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - int year; - int week; - int weekday; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 3, 3, 0, argsbuf); - if (!fastargs) { - goto exit; - } - if (PyFloat_Check(fastargs[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - year = _PyLong_AsInt(fastargs[0]); - if (year == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - week = _PyLong_AsInt(fastargs[1]); - if (week == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(fastargs[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - weekday = _PyLong_AsInt(fastargs[2]); - if (weekday == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = iso_calendar_date_new_impl(type, year, week, weekday); - -exit: - return return_value; -} - +PyDoc_STRVAR(datetime_date_fromtimestamp__doc__, +"fromtimestamp($type, timestamp, /)\n" +"--\n" +"\n" +"Create a date from a POSIX timestamp.\n" +"\n" +"The timestamp is a number, e.g. created via time.time(), that is interpreted\n" +"as local time."); + +#define DATETIME_DATE_FROMTIMESTAMP_METHODDEF \ + {"fromtimestamp", (PyCFunction)datetime_date_fromtimestamp, METH_O|METH_CLASS, datetime_date_fromtimestamp__doc__}, + +static PyObject * +iso_calendar_date_new_impl(PyTypeObject *type, int year, int week, + int weekday); + +static PyObject * +iso_calendar_date_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"year", "week", "weekday", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "IsoCalendarDate", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + int year; + int week; + int weekday; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 3, 3, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (PyFloat_Check(fastargs[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + year = _PyLong_AsInt(fastargs[0]); + if (year == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + week = _PyLong_AsInt(fastargs[1]); + if (week == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + weekday = _PyLong_AsInt(fastargs[2]); + if (weekday == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = iso_calendar_date_new_impl(type, year, week, weekday); + +exit: + return return_value; +} + PyDoc_STRVAR(datetime_datetime_now__doc__, "now($type, /, tz=None)\n" "--\n" @@ -80,7 +80,7 @@ PyDoc_STRVAR(datetime_datetime_now__doc__, "If no tz is specified, uses local timezone."); #define DATETIME_DATETIME_NOW_METHODDEF \ - {"now", (PyCFunction)(void(*)(void))datetime_datetime_now, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, + {"now", (PyCFunction)(void(*)(void))datetime_datetime_now, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, static PyObject * datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz); @@ -90,23 +90,23 @@ datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"tz", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "now", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "now", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *tz = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - tz = args[0]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + tz = args[0]; +skip_optional_pos: return_value = datetime_datetime_now_impl(type, tz); exit: return return_value; } -/*[clinic end generated code: output=5e17549f29a439a5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5e17549f29a439a5 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h index a7d7350850..963cbdb3cb 100644 --- a/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h @@ -45,7 +45,7 @@ PyDoc_STRVAR(_dbm_dbm_get__doc__, "Return the value for key if present, otherwise default."); #define _DBM_DBM_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_dbm_dbm_get, METH_FASTCALL, _dbm_dbm_get__doc__}, + {"get", (PyCFunction)(void(*)(void))_dbm_dbm_get, METH_FASTCALL, _dbm_dbm_get__doc__}, static PyObject * _dbm_dbm_get_impl(dbmobject *self, const char *key, @@ -78,7 +78,7 @@ PyDoc_STRVAR(_dbm_dbm_setdefault__doc__, "If key is not in the database, it is inserted with default as the value."); #define _DBM_DBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))_dbm_dbm_setdefault, METH_FASTCALL, _dbm_dbm_setdefault__doc__}, + {"setdefault", (PyCFunction)(void(*)(void))_dbm_dbm_setdefault, METH_FASTCALL, _dbm_dbm_setdefault__doc__}, static PyObject * _dbm_dbm_setdefault_impl(dbmobject *self, const char *key, @@ -118,7 +118,7 @@ PyDoc_STRVAR(dbmopen__doc__, " (e.g. os.O_RDWR)."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, + {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, @@ -132,49 +132,49 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *flags = "r"; int mode = 438; - if (!_PyArg_CheckPositional("open", nargs, 1, 3)) { + if (!_PyArg_CheckPositional("open", nargs, 1, 3)) { goto exit; } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("open", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - filename = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("open", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t flags_length; - flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); - if (flags == NULL) { - goto exit; - } - if (strlen(flags) != (size_t)flags_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[2]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("open", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + filename = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("open", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t flags_length; + flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); + if (flags == NULL) { + goto exit; + } + if (strlen(flags) != (size_t)flags_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[2]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = dbmopen_impl(module, filename, flags, mode); exit: return return_value; } -/*[clinic end generated code: output=7ced103488cbca7a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7ced103488cbca7a input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_elementtree.c.h b/contrib/tools/python3/src/Modules/clinic/_elementtree.c.h index 825416f4a3..03b78f4ff8 100644 --- a/contrib/tools/python3/src/Modules/clinic/_elementtree.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_elementtree.c.h @@ -19,11 +19,11 @@ _elementtree_Element_append(ElementObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *subelement; - if (!PyObject_TypeCheck(arg, &Element_Type)) { - _PyArg_BadArgument("append", "argument", (&Element_Type)->tp_name, arg); + if (!PyObject_TypeCheck(arg, &Element_Type)) { + _PyArg_BadArgument("append", "argument", (&Element_Type)->tp_name, arg); goto exit; } - subelement = arg; + subelement = arg; return_value = _elementtree_Element_append_impl(self, subelement); exit: @@ -81,11 +81,11 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *memo; - if (!PyDict_Check(arg)) { - _PyArg_BadArgument("__deepcopy__", "argument", "dict", arg); + if (!PyDict_Check(arg)) { + _PyArg_BadArgument("__deepcopy__", "argument", "dict", arg); goto exit; } - memo = arg; + memo = arg; return_value = _elementtree_Element___deepcopy___impl(self, memo); exit: @@ -158,7 +158,7 @@ PyDoc_STRVAR(_elementtree_Element_find__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \ - {"find", (PyCFunction)(void(*)(void))_elementtree_Element_find, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, + {"find", (PyCFunction)(void(*)(void))_elementtree_Element_find, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, static PyObject * _elementtree_Element_find_impl(ElementObject *self, PyObject *path, @@ -169,22 +169,22 @@ _elementtree_Element_find(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "find", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "find", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - path = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - namespaces = args[1]; -skip_optional_pos: + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_find_impl(self, path, namespaces); exit: @@ -197,7 +197,7 @@ PyDoc_STRVAR(_elementtree_Element_findtext__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \ - {"findtext", (PyCFunction)(void(*)(void))_elementtree_Element_findtext, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, + {"findtext", (PyCFunction)(void(*)(void))_elementtree_Element_findtext, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, static PyObject * _elementtree_Element_findtext_impl(ElementObject *self, PyObject *path, @@ -209,29 +209,29 @@ _elementtree_Element_findtext(ElementObject *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "default", "namespaces", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "findtext", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "findtext", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *default_value = Py_None; PyObject *namespaces = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - path = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - default_value = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - namespaces = args[2]; -skip_optional_pos: + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + default_value = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + namespaces = args[2]; +skip_optional_pos: return_value = _elementtree_Element_findtext_impl(self, path, default_value, namespaces); exit: @@ -244,7 +244,7 @@ PyDoc_STRVAR(_elementtree_Element_findall__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \ - {"findall", (PyCFunction)(void(*)(void))_elementtree_Element_findall, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, + {"findall", (PyCFunction)(void(*)(void))_elementtree_Element_findall, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, static PyObject * _elementtree_Element_findall_impl(ElementObject *self, PyObject *path, @@ -255,22 +255,22 @@ _elementtree_Element_findall(ElementObject *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - path = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - namespaces = args[1]; -skip_optional_pos: + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_findall_impl(self, path, namespaces); exit: @@ -283,7 +283,7 @@ PyDoc_STRVAR(_elementtree_Element_iterfind__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \ - {"iterfind", (PyCFunction)(void(*)(void))_elementtree_Element_iterfind, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, + {"iterfind", (PyCFunction)(void(*)(void))_elementtree_Element_iterfind, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, static PyObject * _elementtree_Element_iterfind_impl(ElementObject *self, PyObject *path, @@ -294,22 +294,22 @@ _elementtree_Element_iterfind(ElementObject *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "iterfind", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "iterfind", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - path = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - namespaces = args[1]; -skip_optional_pos: + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_iterfind_impl(self, path, namespaces); exit: @@ -322,7 +322,7 @@ PyDoc_STRVAR(_elementtree_Element_get__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_elementtree_Element_get, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, + {"get", (PyCFunction)(void(*)(void))_elementtree_Element_get, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, static PyObject * _elementtree_Element_get_impl(ElementObject *self, PyObject *key, @@ -333,22 +333,22 @@ _elementtree_Element_get(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "default", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *key; PyObject *default_value = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - key = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - default_value = args[1]; -skip_optional_pos: + key = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[1]; +skip_optional_pos: return_value = _elementtree_Element_get_impl(self, key, default_value); exit: @@ -361,7 +361,7 @@ PyDoc_STRVAR(_elementtree_Element_iter__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \ - {"iter", (PyCFunction)(void(*)(void))_elementtree_Element_iter, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, + {"iter", (PyCFunction)(void(*)(void))_elementtree_Element_iter, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, static PyObject * _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag); @@ -371,20 +371,20 @@ _elementtree_Element_iter(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"tag", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "iter", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "iter", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *tag = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - tag = args[0]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + tag = args[0]; +skip_optional_pos: return_value = _elementtree_Element_iter_impl(self, tag); exit: @@ -414,7 +414,7 @@ PyDoc_STRVAR(_elementtree_Element_insert__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))_elementtree_Element_insert, METH_FASTCALL, _elementtree_Element_insert__doc__}, + {"insert", (PyCFunction)(void(*)(void))_elementtree_Element_insert, METH_FASTCALL, _elementtree_Element_insert__doc__}, static PyObject * _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, @@ -427,31 +427,31 @@ _elementtree_Element_insert(ElementObject *self, PyObject *const *args, Py_ssize Py_ssize_t index; PyObject *subelement; - if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - index = ival; - } - if (!PyObject_TypeCheck(args[1], &Element_Type)) { - _PyArg_BadArgument("insert", "argument 2", (&Element_Type)->tp_name, args[1]); - goto exit; - } - subelement = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + index = ival; + } + if (!PyObject_TypeCheck(args[1], &Element_Type)) { + _PyArg_BadArgument("insert", "argument 2", (&Element_Type)->tp_name, args[1]); + goto exit; + } + subelement = args[1]; return_value = _elementtree_Element_insert_impl(self, index, subelement); exit: @@ -498,7 +498,7 @@ PyDoc_STRVAR(_elementtree_Element_makeelement__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \ - {"makeelement", (PyCFunction)(void(*)(void))_elementtree_Element_makeelement, METH_FASTCALL, _elementtree_Element_makeelement__doc__}, + {"makeelement", (PyCFunction)(void(*)(void))_elementtree_Element_makeelement, METH_FASTCALL, _elementtree_Element_makeelement__doc__}, static PyObject * _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag, @@ -511,15 +511,15 @@ _elementtree_Element_makeelement(ElementObject *self, PyObject *const *args, Py_ PyObject *tag; PyObject *attrib; - if (!_PyArg_CheckPositional("makeelement", nargs, 2, 2)) { - goto exit; - } - tag = args[0]; - if (!PyDict_Check(args[1])) { - _PyArg_BadArgument("makeelement", "argument 2", "dict", args[1]); + if (!_PyArg_CheckPositional("makeelement", nargs, 2, 2)) { goto exit; } - attrib = args[1]; + tag = args[0]; + if (!PyDict_Check(args[1])) { + _PyArg_BadArgument("makeelement", "argument 2", "dict", args[1]); + goto exit; + } + attrib = args[1]; return_value = _elementtree_Element_makeelement_impl(self, tag, attrib); exit: @@ -543,11 +543,11 @@ _elementtree_Element_remove(ElementObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *subelement; - if (!PyObject_TypeCheck(arg, &Element_Type)) { - _PyArg_BadArgument("remove", "argument", (&Element_Type)->tp_name, arg); + if (!PyObject_TypeCheck(arg, &Element_Type)) { + _PyArg_BadArgument("remove", "argument", (&Element_Type)->tp_name, arg); goto exit; } - subelement = arg; + subelement = arg; return_value = _elementtree_Element_remove_impl(self, subelement); exit: @@ -560,7 +560,7 @@ PyDoc_STRVAR(_elementtree_Element_set__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_SET_METHODDEF \ - {"set", (PyCFunction)(void(*)(void))_elementtree_Element_set, METH_FASTCALL, _elementtree_Element_set__doc__}, + {"set", (PyCFunction)(void(*)(void))_elementtree_Element_set, METH_FASTCALL, _elementtree_Element_set__doc__}, static PyObject * _elementtree_Element_set_impl(ElementObject *self, PyObject *key, @@ -573,11 +573,11 @@ _elementtree_Element_set(ElementObject *self, PyObject *const *args, Py_ssize_t PyObject *key; PyObject *value; - if (!_PyArg_CheckPositional("set", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("set", nargs, 2, 2)) { goto exit; } - key = args[0]; - value = args[1]; + key = args[0]; + value = args[1]; return_value = _elementtree_Element_set_impl(self, key, value); exit: @@ -586,109 +586,109 @@ exit: static int _elementtree_TreeBuilder___init___impl(TreeBuilderObject *self, - PyObject *element_factory, - PyObject *comment_factory, - PyObject *pi_factory, - int insert_comments, int insert_pis); + PyObject *element_factory, + PyObject *comment_factory, + PyObject *pi_factory, + int insert_comments, int insert_pis); static int _elementtree_TreeBuilder___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"element_factory", "comment_factory", "pi_factory", "insert_comments", "insert_pis", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "TreeBuilder", 0}; - PyObject *argsbuf[5]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; - PyObject *element_factory = Py_None; - PyObject *comment_factory = Py_None; - PyObject *pi_factory = Py_None; - int insert_comments = 0; - int insert_pis = 0; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); - if (!fastargs) { + static const char * const _keywords[] = {"element_factory", "comment_factory", "pi_factory", "insert_comments", "insert_pis", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "TreeBuilder", 0}; + PyObject *argsbuf[5]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + PyObject *element_factory = Py_None; + PyObject *comment_factory = Py_None; + PyObject *pi_factory = Py_None; + int insert_comments = 0; + int insert_pis = 0; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[0]) { - element_factory = fastargs[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (fastargs[1]) { - comment_factory = fastargs[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[2]) { - pi_factory = fastargs[2]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[3]) { - insert_comments = PyObject_IsTrue(fastargs[3]); - if (insert_comments < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - insert_pis = PyObject_IsTrue(fastargs[4]); - if (insert_pis < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory, comment_factory, pi_factory, insert_comments, insert_pis); - -exit: - return return_value; -} - -PyDoc_STRVAR(_elementtree__set_factories__doc__, -"_set_factories($module, comment_factory, pi_factory, /)\n" -"--\n" -"\n" -"Change the factories used to create comments and processing instructions.\n" -"\n" -"For internal use only."); - -#define _ELEMENTTREE__SET_FACTORIES_METHODDEF \ - {"_set_factories", (PyCFunction)(void(*)(void))_elementtree__set_factories, METH_FASTCALL, _elementtree__set_factories__doc__}, - -static PyObject * -_elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory, - PyObject *pi_factory); - -static PyObject * -_elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *comment_factory; - PyObject *pi_factory; - - if (!_PyArg_CheckPositional("_set_factories", nargs, 2, 2)) { - goto exit; - } - comment_factory = args[0]; - pi_factory = args[1]; - return_value = _elementtree__set_factories_impl(module, comment_factory, pi_factory); + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + element_factory = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + comment_factory = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + pi_factory = fastargs[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + insert_comments = PyObject_IsTrue(fastargs[3]); + if (insert_comments < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + insert_pis = PyObject_IsTrue(fastargs[4]); + if (insert_pis < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory, comment_factory, pi_factory, insert_comments, insert_pis); exit: return return_value; } +PyDoc_STRVAR(_elementtree__set_factories__doc__, +"_set_factories($module, comment_factory, pi_factory, /)\n" +"--\n" +"\n" +"Change the factories used to create comments and processing instructions.\n" +"\n" +"For internal use only."); + +#define _ELEMENTTREE__SET_FACTORIES_METHODDEF \ + {"_set_factories", (PyCFunction)(void(*)(void))_elementtree__set_factories, METH_FASTCALL, _elementtree__set_factories__doc__}, + +static PyObject * +_elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory, + PyObject *pi_factory); + +static PyObject * +_elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *comment_factory; + PyObject *pi_factory; + + if (!_PyArg_CheckPositional("_set_factories", nargs, 2, 2)) { + goto exit; + } + comment_factory = args[0]; + pi_factory = args[1]; + return_value = _elementtree__set_factories_impl(module, comment_factory, pi_factory); + +exit: + return return_value; +} + PyDoc_STRVAR(_elementtree_TreeBuilder_data__doc__, "data($self, data, /)\n" "--\n" @@ -705,48 +705,48 @@ PyDoc_STRVAR(_elementtree_TreeBuilder_end__doc__, #define _ELEMENTTREE_TREEBUILDER_END_METHODDEF \ {"end", (PyCFunction)_elementtree_TreeBuilder_end, METH_O, _elementtree_TreeBuilder_end__doc__}, -PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__, -"comment($self, text, /)\n" -"--\n" -"\n"); - -#define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \ - {"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__}, - -PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__, -"pi($self, target, text=None, /)\n" -"--\n" -"\n"); - -#define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \ - {"pi", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_pi, METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, - -static PyObject * -_elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target, - PyObject *text); - -static PyObject * -_elementtree_TreeBuilder_pi(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *target; - PyObject *text = Py_None; - - if (!_PyArg_CheckPositional("pi", nargs, 1, 2)) { - goto exit; - } - target = args[0]; - if (nargs < 2) { - goto skip_optional; - } - text = args[1]; -skip_optional: - return_value = _elementtree_TreeBuilder_pi_impl(self, target, text); - -exit: - return return_value; -} - +PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__, +"comment($self, text, /)\n" +"--\n" +"\n"); + +#define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \ + {"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__}, + +PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__, +"pi($self, target, text=None, /)\n" +"--\n" +"\n"); + +#define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \ + {"pi", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_pi, METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, + +static PyObject * +_elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target, + PyObject *text); + +static PyObject * +_elementtree_TreeBuilder_pi(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *target; + PyObject *text = Py_None; + + if (!_PyArg_CheckPositional("pi", nargs, 1, 2)) { + goto exit; + } + target = args[0]; + if (nargs < 2) { + goto skip_optional; + } + text = args[1]; +skip_optional: + return_value = _elementtree_TreeBuilder_pi_impl(self, target, text); + +exit: + return return_value; +} + PyDoc_STRVAR(_elementtree_TreeBuilder_close__doc__, "close($self, /)\n" "--\n" @@ -765,12 +765,12 @@ _elementtree_TreeBuilder_close(TreeBuilderObject *self, PyObject *Py_UNUSED(igno } PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__, -"start($self, tag, attrs, /)\n" +"start($self, tag, attrs, /)\n" "--\n" "\n"); #define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_start, METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, + {"start", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_start, METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, static PyObject * _elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag, @@ -781,17 +781,17 @@ _elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject *const *args, P { PyObject *return_value = NULL; PyObject *tag; - PyObject *attrs; + PyObject *attrs; - if (!_PyArg_CheckPositional("start", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("start", nargs, 2, 2)) { goto exit; } - tag = args[0]; - if (!PyDict_Check(args[1])) { - _PyArg_BadArgument("start", "argument 2", "dict", args[1]); - goto exit; - } - attrs = args[1]; + tag = args[0]; + if (!PyDict_Check(args[1])) { + _PyArg_BadArgument("start", "argument 2", "dict", args[1]); + goto exit; + } + attrs = args[1]; return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs); exit: @@ -799,55 +799,55 @@ exit: } static int -_elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target, - const char *encoding); +_elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target, + const char *encoding); static int _elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"target", "encoding", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "XMLParser", 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; + static const char * const _keywords[] = {"target", "encoding", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "XMLParser", 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; PyObject *target = NULL; const char *encoding = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); - if (!fastargs) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (fastargs[0]) { - target = fastargs[0]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[1] == Py_None) { - encoding = NULL; - } - else if (PyUnicode_Check(fastargs[1])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]); + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); + if (!fastargs) { goto exit; } -skip_optional_kwonly: - return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding); + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[0]) { + target = fastargs[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[1] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(fastargs[1])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]); + goto exit; + } +skip_optional_kwonly: + return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding); exit: return return_value; @@ -892,7 +892,7 @@ PyDoc_STRVAR(_elementtree_XMLParser__setevents__doc__, "\n"); #define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \ - {"_setevents", (PyCFunction)(void(*)(void))_elementtree_XMLParser__setevents, METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, + {"_setevents", (PyCFunction)(void(*)(void))_elementtree_XMLParser__setevents, METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, static PyObject * _elementtree_XMLParser__setevents_impl(XMLParserObject *self, @@ -906,18 +906,18 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args, PyObject *events_queue; PyObject *events_to_report = Py_None; - if (!_PyArg_CheckPositional("_setevents", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("_setevents", nargs, 1, 2)) { goto exit; } - events_queue = args[0]; - if (nargs < 2) { - goto skip_optional; - } - events_to_report = args[1]; -skip_optional: + events_queue = args[0]; + if (nargs < 2) { + goto skip_optional; + } + events_to_report = args[1]; +skip_optional: return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report); exit: return return_value; } -/*[clinic end generated code: output=b7f6a32462fc42a9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b7f6a32462fc42a9 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h index 552bf6ed88..473cd98027 100644 --- a/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_gdbm_gdbm_get__doc__, "Get the value for key, or default if not present."); #define _GDBM_GDBM_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_gdbm_gdbm_get, METH_FASTCALL, _gdbm_gdbm_get__doc__}, + {"get", (PyCFunction)(void(*)(void))_gdbm_gdbm_get, METH_FASTCALL, _gdbm_gdbm_get__doc__}, static PyObject * _gdbm_gdbm_get_impl(dbmobject *self, PyObject *key, PyObject *default_value); @@ -21,15 +21,15 @@ _gdbm_gdbm_get(dbmobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *key; PyObject *default_value = Py_None; - if (!_PyArg_CheckPositional("get", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("get", nargs, 1, 2)) { goto exit; } - key = args[0]; - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + key = args[0]; + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = _gdbm_gdbm_get_impl(self, key, default_value); exit: @@ -43,7 +43,7 @@ PyDoc_STRVAR(_gdbm_gdbm_setdefault__doc__, "Get value for key, or set it to default and return default if not present."); #define _GDBM_GDBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))_gdbm_gdbm_setdefault, METH_FASTCALL, _gdbm_gdbm_setdefault__doc__}, + {"setdefault", (PyCFunction)(void(*)(void))_gdbm_gdbm_setdefault, METH_FASTCALL, _gdbm_gdbm_setdefault__doc__}, static PyObject * _gdbm_gdbm_setdefault_impl(dbmobject *self, PyObject *key, @@ -56,15 +56,15 @@ _gdbm_gdbm_setdefault(dbmobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *key; PyObject *default_value = Py_None; - if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) { goto exit; } - key = args[0]; - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + key = args[0]; + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = _gdbm_gdbm_setdefault_impl(self, key, default_value); exit: @@ -139,7 +139,7 @@ PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__, "to create a list in memory that contains them all:\n" "\n" " k = db.firstkey()\n" -" while k is not None:\n" +" while k is not None:\n" " print(k)\n" " k = db.nextkey(k)"); @@ -239,7 +239,7 @@ PyDoc_STRVAR(dbmopen__doc__, "when the database has to be created. It defaults to octal 0o666."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, + {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, @@ -253,49 +253,49 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *flags = "r"; int mode = 438; - if (!_PyArg_CheckPositional("open", nargs, 1, 3)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("open", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - filename = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("open", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t flags_length; - flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); - if (flags == NULL) { - goto exit; - } - if (strlen(flags) != (size_t)flags_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[2]); - if (mode == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("open", nargs, 1, 3)) { goto exit; } -skip_optional: + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("open", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + filename = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("open", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t flags_length; + flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); + if (flags == NULL) { + goto exit; + } + if (strlen(flags) != (size_t)flags_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[2]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = dbmopen_impl(module, filename, flags, mode); exit: return return_value; } -/*[clinic end generated code: output=f48d6e8d4c8a3465 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f48d6e8d4c8a3465 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_hashopenssl.c.h b/contrib/tools/python3/src/Modules/clinic/_hashopenssl.c.h index 68aa765e52..c3f0139edf 100644 --- a/contrib/tools/python3/src/Modules/clinic/_hashopenssl.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_hashopenssl.c.h @@ -2,969 +2,969 @@ preserve [clinic start generated code]*/ -PyDoc_STRVAR(EVP_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of the hash object."); - -#define EVP_COPY_METHODDEF \ - {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__}, - -static PyObject * -EVP_copy_impl(EVPobject *self); - -static PyObject * -EVP_copy(EVPobject *self, PyObject *Py_UNUSED(ignored)) -{ - return EVP_copy_impl(self); -} - -PyDoc_STRVAR(EVP_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a bytes object."); - -#define EVP_DIGEST_METHODDEF \ - {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__}, - -static PyObject * -EVP_digest_impl(EVPobject *self); - -static PyObject * -EVP_digest(EVPobject *self, PyObject *Py_UNUSED(ignored)) -{ - return EVP_digest_impl(self); -} - -PyDoc_STRVAR(EVP_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define EVP_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__}, - -static PyObject * -EVP_hexdigest_impl(EVPobject *self); - -static PyObject * -EVP_hexdigest(EVPobject *self, PyObject *Py_UNUSED(ignored)) -{ - return EVP_hexdigest_impl(self); -} - -PyDoc_STRVAR(EVP_update__doc__, -"update($self, obj, /)\n" -"--\n" -"\n" -"Update this hash object\'s state with the provided string."); - -#define EVP_UPDATE_METHODDEF \ - {"update", (PyCFunction)EVP_update, METH_O, EVP_update__doc__}, - -#if defined(PY_OPENSSL_HAS_SHAKE) - -PyDoc_STRVAR(EVPXOF_digest__doc__, -"digest($self, /, length)\n" -"--\n" -"\n" -"Return the digest value as a bytes object."); - -#define EVPXOF_DIGEST_METHODDEF \ - {"digest", (PyCFunction)(void(*)(void))EVPXOF_digest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__}, - -static PyObject * -EVPXOF_digest_impl(EVPobject *self, Py_ssize_t length); - -static PyObject * -EVPXOF_digest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "digest", 0}; - PyObject *argsbuf[1]; - Py_ssize_t length; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - length = ival; - } - return_value = EVPXOF_digest_impl(self, length); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ - -#if defined(PY_OPENSSL_HAS_SHAKE) - -PyDoc_STRVAR(EVPXOF_hexdigest__doc__, -"hexdigest($self, /, length)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define EVPXOF_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)(void(*)(void))EVPXOF_hexdigest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__}, - -static PyObject * -EVPXOF_hexdigest_impl(EVPobject *self, Py_ssize_t length); - -static PyObject * -EVPXOF_hexdigest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hexdigest", 0}; - PyObject *argsbuf[1]; - Py_ssize_t length; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - length = ival; - } - return_value = EVPXOF_hexdigest_impl(self, length); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ - -PyDoc_STRVAR(EVP_new__doc__, -"new($module, /, name, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Return a new hash object using the named algorithm.\n" -"\n" -"An optional string argument may be provided and will be\n" -"automatically hashed.\n" -"\n" -"The MD5 and SHA1 algorithms are always supported."); - -#define EVP_NEW_METHODDEF \ - {"new", (PyCFunction)(void(*)(void))EVP_new, METH_FASTCALL|METH_KEYWORDS, EVP_new__doc__}, - -static PyObject * -EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -EVP_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"name", "string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "new", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - PyObject *name_obj; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - name_obj = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - data_obj = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[2]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = EVP_new_impl(module, name_obj, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_md5__doc__, -"openssl_md5($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a md5 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_MD5_METHODDEF \ - {"openssl_md5", (PyCFunction)(void(*)(void))_hashlib_openssl_md5, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__}, - -static PyObject * -_hashlib_openssl_md5_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_md5", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_md5_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_sha1__doc__, -"openssl_sha1($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha1 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA1_METHODDEF \ - {"openssl_sha1", (PyCFunction)(void(*)(void))_hashlib_openssl_sha1, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__}, - -static PyObject * -_hashlib_openssl_sha1_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha1", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha1_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_sha224__doc__, -"openssl_sha224($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha224 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA224_METHODDEF \ - {"openssl_sha224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__}, - -static PyObject * -_hashlib_openssl_sha224_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha224", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha224_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_sha256__doc__, -"openssl_sha256($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha256 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA256_METHODDEF \ - {"openssl_sha256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__}, - -static PyObject * -_hashlib_openssl_sha256_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha256", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha256_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_sha384__doc__, -"openssl_sha384($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha384 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA384_METHODDEF \ - {"openssl_sha384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__}, - -static PyObject * -_hashlib_openssl_sha384_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha384", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha384_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_openssl_sha512__doc__, -"openssl_sha512($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha512 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA512_METHODDEF \ - {"openssl_sha512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__}, - -static PyObject * -_hashlib_openssl_sha512_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha512", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha512_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#if defined(PY_OPENSSL_HAS_SHA3) - -PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__, -"openssl_sha3_224($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha3-224 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA3_224_METHODDEF \ - {"openssl_sha3_224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__}, - -static PyObject * -_hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_224", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha3_224_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHA3) */ - -#if defined(PY_OPENSSL_HAS_SHA3) - -PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__, -"openssl_sha3_256($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha3-256 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA3_256_METHODDEF \ - {"openssl_sha3_256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__}, - -static PyObject * -_hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_256", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha3_256_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHA3) */ - -#if defined(PY_OPENSSL_HAS_SHA3) - -PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__, -"openssl_sha3_384($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha3-384 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA3_384_METHODDEF \ - {"openssl_sha3_384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__}, - -static PyObject * -_hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_384", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha3_384_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHA3) */ - -#if defined(PY_OPENSSL_HAS_SHA3) - -PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__, -"openssl_sha3_512($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a sha3-512 hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHA3_512_METHODDEF \ - {"openssl_sha3_512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__}, - -static PyObject * -_hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_512", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_sha3_512_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHA3) */ - -#if defined(PY_OPENSSL_HAS_SHAKE) - -PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__, -"openssl_shake_128($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a shake-128 variable hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF \ - {"openssl_shake_128", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_128, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__}, - -static PyObject * -_hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_128", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_shake_128_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ - -#if defined(PY_OPENSSL_HAS_SHAKE) - -PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__, -"openssl_shake_256($module, /, string=b\'\', *, usedforsecurity=True)\n" -"--\n" -"\n" -"Returns a shake-256 variable hash object; optionally initialized with a string"); - -#define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF \ - {"openssl_shake_256", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__}, - -static PyObject * -_hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data_obj, - int usedforsecurity); - -static PyObject * -_hashlib_openssl_shake_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_256", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *data_obj = NULL; - int usedforsecurity = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - data_obj = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _hashlib_openssl_shake_256_impl(module, data_obj, usedforsecurity); - -exit: - return return_value; -} - -#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ - -PyDoc_STRVAR(pbkdf2_hmac__doc__, -"pbkdf2_hmac($module, /, hash_name, password, salt, iterations,\n" -" dklen=None)\n" -"--\n" -"\n" -"Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as pseudorandom function."); - -#define PBKDF2_HMAC_METHODDEF \ - {"pbkdf2_hmac", (PyCFunction)(void(*)(void))pbkdf2_hmac, METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__}, - -static PyObject * -pbkdf2_hmac_impl(PyObject *module, const char *hash_name, - Py_buffer *password, Py_buffer *salt, long iterations, - PyObject *dklen_obj); - -static PyObject * -pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"hash_name", "password", "salt", "iterations", "dklen", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "pbkdf2_hmac", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; - const char *hash_name; - Py_buffer password = {NULL, NULL}; - Py_buffer salt = {NULL, NULL}; - long iterations; - PyObject *dklen_obj = Py_None; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 5, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]); - goto exit; - } - Py_ssize_t hash_name_length; - hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length); - if (hash_name == NULL) { - goto exit; - } - if (strlen(hash_name) != (size_t)hash_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&password, 'C')) { - _PyArg_BadArgument("pbkdf2_hmac", "argument 'password'", "contiguous buffer", args[1]); - goto exit; - } - if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&salt, 'C')) { - _PyArg_BadArgument("pbkdf2_hmac", "argument 'salt'", "contiguous buffer", args[2]); - goto exit; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - iterations = PyLong_AsLong(args[3]); - if (iterations == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - dklen_obj = args[4]; -skip_optional_pos: - return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj); - -exit: - /* Cleanup for password */ - if (password.obj) { - PyBuffer_Release(&password); - } - /* Cleanup for salt */ - if (salt.obj) { - PyBuffer_Release(&salt); - } - - return return_value; -} - +PyDoc_STRVAR(EVP_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of the hash object."); + +#define EVP_COPY_METHODDEF \ + {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__}, + +static PyObject * +EVP_copy_impl(EVPobject *self); + +static PyObject * +EVP_copy(EVPobject *self, PyObject *Py_UNUSED(ignored)) +{ + return EVP_copy_impl(self); +} + +PyDoc_STRVAR(EVP_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a bytes object."); + +#define EVP_DIGEST_METHODDEF \ + {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__}, + +static PyObject * +EVP_digest_impl(EVPobject *self); + +static PyObject * +EVP_digest(EVPobject *self, PyObject *Py_UNUSED(ignored)) +{ + return EVP_digest_impl(self); +} + +PyDoc_STRVAR(EVP_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define EVP_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__}, + +static PyObject * +EVP_hexdigest_impl(EVPobject *self); + +static PyObject * +EVP_hexdigest(EVPobject *self, PyObject *Py_UNUSED(ignored)) +{ + return EVP_hexdigest_impl(self); +} + +PyDoc_STRVAR(EVP_update__doc__, +"update($self, obj, /)\n" +"--\n" +"\n" +"Update this hash object\'s state with the provided string."); + +#define EVP_UPDATE_METHODDEF \ + {"update", (PyCFunction)EVP_update, METH_O, EVP_update__doc__}, + +#if defined(PY_OPENSSL_HAS_SHAKE) + +PyDoc_STRVAR(EVPXOF_digest__doc__, +"digest($self, /, length)\n" +"--\n" +"\n" +"Return the digest value as a bytes object."); + +#define EVPXOF_DIGEST_METHODDEF \ + {"digest", (PyCFunction)(void(*)(void))EVPXOF_digest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__}, + +static PyObject * +EVPXOF_digest_impl(EVPobject *self, Py_ssize_t length); + +static PyObject * +EVPXOF_digest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"length", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "digest", 0}; + PyObject *argsbuf[1]; + Py_ssize_t length; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + return_value = EVPXOF_digest_impl(self, length); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ + +#if defined(PY_OPENSSL_HAS_SHAKE) + +PyDoc_STRVAR(EVPXOF_hexdigest__doc__, +"hexdigest($self, /, length)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define EVPXOF_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)(void(*)(void))EVPXOF_hexdigest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__}, + +static PyObject * +EVPXOF_hexdigest_impl(EVPobject *self, Py_ssize_t length); + +static PyObject * +EVPXOF_hexdigest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"length", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hexdigest", 0}; + PyObject *argsbuf[1]; + Py_ssize_t length; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + return_value = EVPXOF_hexdigest_impl(self, length); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ + +PyDoc_STRVAR(EVP_new__doc__, +"new($module, /, name, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Return a new hash object using the named algorithm.\n" +"\n" +"An optional string argument may be provided and will be\n" +"automatically hashed.\n" +"\n" +"The MD5 and SHA1 algorithms are always supported."); + +#define EVP_NEW_METHODDEF \ + {"new", (PyCFunction)(void(*)(void))EVP_new, METH_FASTCALL|METH_KEYWORDS, EVP_new__doc__}, + +static PyObject * +EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +EVP_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"name", "string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "new", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *name_obj; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + name_obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + data_obj = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[2]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = EVP_new_impl(module, name_obj, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_md5__doc__, +"openssl_md5($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a md5 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_MD5_METHODDEF \ + {"openssl_md5", (PyCFunction)(void(*)(void))_hashlib_openssl_md5, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__}, + +static PyObject * +_hashlib_openssl_md5_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_md5", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_md5_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_sha1__doc__, +"openssl_sha1($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha1 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA1_METHODDEF \ + {"openssl_sha1", (PyCFunction)(void(*)(void))_hashlib_openssl_sha1, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__}, + +static PyObject * +_hashlib_openssl_sha1_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha1", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha1_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_sha224__doc__, +"openssl_sha224($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha224 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA224_METHODDEF \ + {"openssl_sha224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__}, + +static PyObject * +_hashlib_openssl_sha224_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha224", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha224_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_sha256__doc__, +"openssl_sha256($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha256 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA256_METHODDEF \ + {"openssl_sha256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__}, + +static PyObject * +_hashlib_openssl_sha256_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha256", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha256_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_sha384__doc__, +"openssl_sha384($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha384 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA384_METHODDEF \ + {"openssl_sha384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__}, + +static PyObject * +_hashlib_openssl_sha384_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha384", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha384_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_openssl_sha512__doc__, +"openssl_sha512($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha512 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA512_METHODDEF \ + {"openssl_sha512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__}, + +static PyObject * +_hashlib_openssl_sha512_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha512", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha512_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#if defined(PY_OPENSSL_HAS_SHA3) + +PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__, +"openssl_sha3_224($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha3-224 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA3_224_METHODDEF \ + {"openssl_sha3_224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__}, + +static PyObject * +_hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_224", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha3_224_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHA3) */ + +#if defined(PY_OPENSSL_HAS_SHA3) + +PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__, +"openssl_sha3_256($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha3-256 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA3_256_METHODDEF \ + {"openssl_sha3_256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__}, + +static PyObject * +_hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_256", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha3_256_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHA3) */ + +#if defined(PY_OPENSSL_HAS_SHA3) + +PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__, +"openssl_sha3_384($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha3-384 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA3_384_METHODDEF \ + {"openssl_sha3_384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__}, + +static PyObject * +_hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_384", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha3_384_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHA3) */ + +#if defined(PY_OPENSSL_HAS_SHA3) + +PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__, +"openssl_sha3_512($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a sha3-512 hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHA3_512_METHODDEF \ + {"openssl_sha3_512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__}, + +static PyObject * +_hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_512", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_sha3_512_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHA3) */ + +#if defined(PY_OPENSSL_HAS_SHAKE) + +PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__, +"openssl_shake_128($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a shake-128 variable hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF \ + {"openssl_shake_128", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_128, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__}, + +static PyObject * +_hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_128", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_shake_128_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ + +#if defined(PY_OPENSSL_HAS_SHAKE) + +PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__, +"openssl_shake_256($module, /, string=b\'\', *, usedforsecurity=True)\n" +"--\n" +"\n" +"Returns a shake-256 variable hash object; optionally initialized with a string"); + +#define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF \ + {"openssl_shake_256", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__}, + +static PyObject * +_hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data_obj, + int usedforsecurity); + +static PyObject * +_hashlib_openssl_shake_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_256", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_obj = NULL; + int usedforsecurity = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _hashlib_openssl_shake_256_impl(module, data_obj, usedforsecurity); + +exit: + return return_value; +} + +#endif /* defined(PY_OPENSSL_HAS_SHAKE) */ + +PyDoc_STRVAR(pbkdf2_hmac__doc__, +"pbkdf2_hmac($module, /, hash_name, password, salt, iterations,\n" +" dklen=None)\n" +"--\n" +"\n" +"Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as pseudorandom function."); + +#define PBKDF2_HMAC_METHODDEF \ + {"pbkdf2_hmac", (PyCFunction)(void(*)(void))pbkdf2_hmac, METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__}, + +static PyObject * +pbkdf2_hmac_impl(PyObject *module, const char *hash_name, + Py_buffer *password, Py_buffer *salt, long iterations, + PyObject *dklen_obj); + +static PyObject * +pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"hash_name", "password", "salt", "iterations", "dklen", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "pbkdf2_hmac", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; + const char *hash_name; + Py_buffer password = {NULL, NULL}; + Py_buffer salt = {NULL, NULL}; + long iterations; + PyObject *dklen_obj = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 5, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]); + goto exit; + } + Py_ssize_t hash_name_length; + hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length); + if (hash_name == NULL) { + goto exit; + } + if (strlen(hash_name) != (size_t)hash_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&password, 'C')) { + _PyArg_BadArgument("pbkdf2_hmac", "argument 'password'", "contiguous buffer", args[1]); + goto exit; + } + if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("pbkdf2_hmac", "argument 'salt'", "contiguous buffer", args[2]); + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + iterations = PyLong_AsLong(args[3]); + if (iterations == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + dklen_obj = args[4]; +skip_optional_pos: + return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj); + +exit: + /* Cleanup for password */ + if (password.obj) { + PyBuffer_Release(&password); + } + /* Cleanup for salt */ + if (salt.obj) { + PyBuffer_Release(&salt); + } + + return return_value; +} + #if (OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)) PyDoc_STRVAR(_hashlib_scrypt__doc__, @@ -975,7 +975,7 @@ PyDoc_STRVAR(_hashlib_scrypt__doc__, "scrypt password-based key derivation function."); #define _HASHLIB_SCRYPT_METHODDEF \ - {"scrypt", (PyCFunction)(void(*)(void))_hashlib_scrypt, METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__}, + {"scrypt", (PyCFunction)(void(*)(void))_hashlib_scrypt, METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__}, static PyObject * _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt, @@ -987,9 +987,9 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"password", "salt", "n", "r", "p", "maxmem", "dklen", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "scrypt", 0}; - PyObject *argsbuf[7]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "scrypt", 0}; + PyObject *argsbuf[7]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer password = {NULL, NULL}; Py_buffer salt = {NULL, NULL}; PyObject *n_obj = Py_None; @@ -998,86 +998,86 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj long maxmem = 0; long dklen = 64; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&password, 'C')) { - _PyArg_BadArgument("scrypt", "argument 'password'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[1]) { - if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&salt, 'C')) { - _PyArg_BadArgument("scrypt", "argument 'salt'", "contiguous buffer", args[1]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[2]) { - if (!PyLong_Check(args[2])) { - _PyArg_BadArgument("scrypt", "argument 'n'", "int", args[2]); - goto exit; - } - n_obj = args[2]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (!PyLong_Check(args[3])) { - _PyArg_BadArgument("scrypt", "argument 'r'", "int", args[3]); - goto exit; - } - r_obj = args[3]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[4]) { - if (!PyLong_Check(args[4])) { - _PyArg_BadArgument("scrypt", "argument 'p'", "int", args[4]); - goto exit; - } - p_obj = args[4]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[5]) { - if (PyFloat_Check(args[5])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - maxmem = PyLong_AsLong(args[5]); - if (maxmem == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - dklen = PyLong_AsLong(args[6]); - if (dklen == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_kwonly: + if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&password, 'C')) { + _PyArg_BadArgument("scrypt", "argument 'password'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("scrypt", "argument 'salt'", "contiguous buffer", args[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyLong_Check(args[2])) { + _PyArg_BadArgument("scrypt", "argument 'n'", "int", args[2]); + goto exit; + } + n_obj = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!PyLong_Check(args[3])) { + _PyArg_BadArgument("scrypt", "argument 'r'", "int", args[3]); + goto exit; + } + r_obj = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + if (!PyLong_Check(args[4])) { + _PyArg_BadArgument("scrypt", "argument 'p'", "int", args[4]); + goto exit; + } + p_obj = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + maxmem = PyLong_AsLong(args[5]); + if (maxmem == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + dklen = PyLong_AsLong(args[6]); + if (dklen == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = _hashlib_scrypt_impl(module, &password, &salt, n_obj, r_obj, p_obj, maxmem, dklen); exit: @@ -1095,62 +1095,62 @@ exit: #endif /* (OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)) */ -PyDoc_STRVAR(_hashlib_hmac_singleshot__doc__, +PyDoc_STRVAR(_hashlib_hmac_singleshot__doc__, "hmac_digest($module, /, key, msg, digest)\n" "--\n" "\n" "Single-shot HMAC."); -#define _HASHLIB_HMAC_SINGLESHOT_METHODDEF \ - {"hmac_digest", (PyCFunction)(void(*)(void))_hashlib_hmac_singleshot, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__}, +#define _HASHLIB_HMAC_SINGLESHOT_METHODDEF \ + {"hmac_digest", (PyCFunction)(void(*)(void))_hashlib_hmac_singleshot, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__}, static PyObject * -_hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key, - Py_buffer *msg, const char *digest); +_hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key, + Py_buffer *msg, const char *digest); static PyObject * -_hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +_hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "msg", "digest", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hmac_digest", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "hmac_digest", 0}; + PyObject *argsbuf[3]; Py_buffer key = {NULL, NULL}; Py_buffer msg = {NULL, NULL}; const char *digest; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } - if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&key, 'C')) { - _PyArg_BadArgument("hmac_digest", "argument 'key'", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&msg, 'C')) { - _PyArg_BadArgument("hmac_digest", "argument 'msg'", "contiguous buffer", args[1]); - goto exit; - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("hmac_digest", "argument 'digest'", "str", args[2]); - goto exit; - } - Py_ssize_t digest_length; - digest = PyUnicode_AsUTF8AndSize(args[2], &digest_length); - if (digest == NULL) { - goto exit; - } - if (strlen(digest) != (size_t)digest_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest); + if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&key, 'C')) { + _PyArg_BadArgument("hmac_digest", "argument 'key'", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&msg, 'C')) { + _PyArg_BadArgument("hmac_digest", "argument 'msg'", "contiguous buffer", args[1]); + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("hmac_digest", "argument 'digest'", "str", args[2]); + goto exit; + } + Py_ssize_t digest_length; + digest = PyUnicode_AsUTF8AndSize(args[2], &digest_length); + if (digest == NULL) { + goto exit; + } + if (strlen(digest) != (size_t)digest_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest); exit: /* Cleanup for key */ @@ -1165,281 +1165,281 @@ exit: return return_value; } -PyDoc_STRVAR(_hashlib_hmac_new__doc__, -"hmac_new($module, /, key, msg=b\'\', digestmod=None)\n" -"--\n" -"\n" -"Return a new hmac object."); - -#define _HASHLIB_HMAC_NEW_METHODDEF \ - {"hmac_new", (PyCFunction)(void(*)(void))_hashlib_hmac_new, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__}, - -static PyObject * -_hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj, - const char *digestmod); - -static PyObject * -_hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"key", "msg", "digestmod", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hmac_new", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - Py_buffer key = {NULL, NULL}; - PyObject *msg_obj = NULL; - const char *digestmod = NULL; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&key, 'C')) { - _PyArg_BadArgument("hmac_new", "argument 'key'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - msg_obj = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("hmac_new", "argument 'digestmod'", "str", args[2]); - goto exit; - } - Py_ssize_t digestmod_length; - digestmod = PyUnicode_AsUTF8AndSize(args[2], &digestmod_length); - if (digestmod == NULL) { - goto exit; - } - if (strlen(digestmod) != (size_t)digestmod_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } -skip_optional_pos: - return_value = _hashlib_hmac_new_impl(module, &key, msg_obj, digestmod); - -exit: - /* Cleanup for key */ - if (key.obj) { - PyBuffer_Release(&key); - } - - return return_value; -} - -PyDoc_STRVAR(_hashlib_HMAC_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy (\"clone\") of the HMAC object."); - -#define _HASHLIB_HMAC_COPY_METHODDEF \ - {"copy", (PyCFunction)_hashlib_HMAC_copy, METH_NOARGS, _hashlib_HMAC_copy__doc__}, - -static PyObject * -_hashlib_HMAC_copy_impl(HMACobject *self); - -static PyObject * -_hashlib_HMAC_copy(HMACobject *self, PyObject *Py_UNUSED(ignored)) -{ - return _hashlib_HMAC_copy_impl(self); -} - -PyDoc_STRVAR(_hashlib_HMAC_update__doc__, -"update($self, /, msg)\n" -"--\n" -"\n" -"Update the HMAC object with msg."); - -#define _HASHLIB_HMAC_UPDATE_METHODDEF \ - {"update", (PyCFunction)(void(*)(void))_hashlib_HMAC_update, METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__}, - -static PyObject * -_hashlib_HMAC_update_impl(HMACobject *self, PyObject *msg); - -static PyObject * -_hashlib_HMAC_update(HMACobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"msg", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "update", 0}; - PyObject *argsbuf[1]; - PyObject *msg; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - msg = args[0]; - return_value = _hashlib_HMAC_update_impl(self, msg); - -exit: - return return_value; -} - -PyDoc_STRVAR(_hashlib_HMAC_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest of the bytes passed to the update() method so far."); - -#define _HASHLIB_HMAC_DIGEST_METHODDEF \ - {"digest", (PyCFunction)_hashlib_HMAC_digest, METH_NOARGS, _hashlib_HMAC_digest__doc__}, - -static PyObject * -_hashlib_HMAC_digest_impl(HMACobject *self); - -static PyObject * -_hashlib_HMAC_digest(HMACobject *self, PyObject *Py_UNUSED(ignored)) -{ - return _hashlib_HMAC_digest_impl(self); -} - -PyDoc_STRVAR(_hashlib_HMAC_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return hexadecimal digest of the bytes passed to the update() method so far.\n" -"\n" -"This may be used to exchange the value safely in email or other non-binary\n" -"environments."); - -#define _HASHLIB_HMAC_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)_hashlib_HMAC_hexdigest, METH_NOARGS, _hashlib_HMAC_hexdigest__doc__}, - -static PyObject * -_hashlib_HMAC_hexdigest_impl(HMACobject *self); - -static PyObject * -_hashlib_HMAC_hexdigest(HMACobject *self, PyObject *Py_UNUSED(ignored)) -{ - return _hashlib_HMAC_hexdigest_impl(self); -} - -#if !defined(LIBRESSL_VERSION_NUMBER) - -PyDoc_STRVAR(_hashlib_get_fips_mode__doc__, -"get_fips_mode($module, /)\n" -"--\n" -"\n" -"Determine the OpenSSL FIPS mode of operation.\n" -"\n" -"For OpenSSL 3.0.0 and newer it returns the state of the default provider\n" -"in the default OSSL context. It\'s not quite the same as FIPS_mode() but good\n" -"enough for unittests.\n" -"\n" -"Effectively any non-zero return value indicates FIPS mode;\n" -"values other than 1 may have additional significance."); - -#define _HASHLIB_GET_FIPS_MODE_METHODDEF \ - {"get_fips_mode", (PyCFunction)_hashlib_get_fips_mode, METH_NOARGS, _hashlib_get_fips_mode__doc__}, - -static int -_hashlib_get_fips_mode_impl(PyObject *module); - -static PyObject * -_hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - int _return_value; - - _return_value = _hashlib_get_fips_mode_impl(module); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - -#endif /* !defined(LIBRESSL_VERSION_NUMBER) */ - -PyDoc_STRVAR(_hashlib_compare_digest__doc__, -"compare_digest($module, a, b, /)\n" -"--\n" -"\n" -"Return \'a == b\'.\n" -"\n" -"This function uses an approach designed to prevent\n" -"timing analysis, making it appropriate for cryptography.\n" -"\n" -"a and b must both be of the same type: either str (ASCII only),\n" -"or any bytes-like object.\n" -"\n" -"Note: If a and b are of different lengths, or if an error occurs,\n" -"a timing attack could theoretically reveal information about the\n" -"types and lengths of a and b--but not their values."); - -#define _HASHLIB_COMPARE_DIGEST_METHODDEF \ - {"compare_digest", (PyCFunction)(void(*)(void))_hashlib_compare_digest, METH_FASTCALL, _hashlib_compare_digest__doc__}, - -static PyObject * -_hashlib_compare_digest_impl(PyObject *module, PyObject *a, PyObject *b); - -static PyObject * -_hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *a; - PyObject *b; - - if (!_PyArg_CheckPositional("compare_digest", nargs, 2, 2)) { - goto exit; - } - a = args[0]; - b = args[1]; - return_value = _hashlib_compare_digest_impl(module, a, b); - -exit: - return return_value; -} - -#ifndef EVPXOF_DIGEST_METHODDEF - #define EVPXOF_DIGEST_METHODDEF -#endif /* !defined(EVPXOF_DIGEST_METHODDEF) */ - -#ifndef EVPXOF_HEXDIGEST_METHODDEF - #define EVPXOF_HEXDIGEST_METHODDEF -#endif /* !defined(EVPXOF_HEXDIGEST_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHA3_224_METHODDEF - #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHA3_224_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHA3_256_METHODDEF - #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHA3_256_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHA3_384_METHODDEF - #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHA3_384_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHA3_512_METHODDEF - #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHA3_512_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHAKE_128_METHODDEF - #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHAKE_128_METHODDEF) */ - -#ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF - #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF -#endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */ - +PyDoc_STRVAR(_hashlib_hmac_new__doc__, +"hmac_new($module, /, key, msg=b\'\', digestmod=None)\n" +"--\n" +"\n" +"Return a new hmac object."); + +#define _HASHLIB_HMAC_NEW_METHODDEF \ + {"hmac_new", (PyCFunction)(void(*)(void))_hashlib_hmac_new, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__}, + +static PyObject * +_hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj, + const char *digestmod); + +static PyObject * +_hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"key", "msg", "digestmod", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hmac_new", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + Py_buffer key = {NULL, NULL}; + PyObject *msg_obj = NULL; + const char *digestmod = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&key, 'C')) { + _PyArg_BadArgument("hmac_new", "argument 'key'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + msg_obj = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("hmac_new", "argument 'digestmod'", "str", args[2]); + goto exit; + } + Py_ssize_t digestmod_length; + digestmod = PyUnicode_AsUTF8AndSize(args[2], &digestmod_length); + if (digestmod == NULL) { + goto exit; + } + if (strlen(digestmod) != (size_t)digestmod_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: + return_value = _hashlib_hmac_new_impl(module, &key, msg_obj, digestmod); + +exit: + /* Cleanup for key */ + if (key.obj) { + PyBuffer_Release(&key); + } + + return return_value; +} + +PyDoc_STRVAR(_hashlib_HMAC_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy (\"clone\") of the HMAC object."); + +#define _HASHLIB_HMAC_COPY_METHODDEF \ + {"copy", (PyCFunction)_hashlib_HMAC_copy, METH_NOARGS, _hashlib_HMAC_copy__doc__}, + +static PyObject * +_hashlib_HMAC_copy_impl(HMACobject *self); + +static PyObject * +_hashlib_HMAC_copy(HMACobject *self, PyObject *Py_UNUSED(ignored)) +{ + return _hashlib_HMAC_copy_impl(self); +} + +PyDoc_STRVAR(_hashlib_HMAC_update__doc__, +"update($self, /, msg)\n" +"--\n" +"\n" +"Update the HMAC object with msg."); + +#define _HASHLIB_HMAC_UPDATE_METHODDEF \ + {"update", (PyCFunction)(void(*)(void))_hashlib_HMAC_update, METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__}, + +static PyObject * +_hashlib_HMAC_update_impl(HMACobject *self, PyObject *msg); + +static PyObject * +_hashlib_HMAC_update(HMACobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"msg", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "update", 0}; + PyObject *argsbuf[1]; + PyObject *msg; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + msg = args[0]; + return_value = _hashlib_HMAC_update_impl(self, msg); + +exit: + return return_value; +} + +PyDoc_STRVAR(_hashlib_HMAC_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest of the bytes passed to the update() method so far."); + +#define _HASHLIB_HMAC_DIGEST_METHODDEF \ + {"digest", (PyCFunction)_hashlib_HMAC_digest, METH_NOARGS, _hashlib_HMAC_digest__doc__}, + +static PyObject * +_hashlib_HMAC_digest_impl(HMACobject *self); + +static PyObject * +_hashlib_HMAC_digest(HMACobject *self, PyObject *Py_UNUSED(ignored)) +{ + return _hashlib_HMAC_digest_impl(self); +} + +PyDoc_STRVAR(_hashlib_HMAC_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return hexadecimal digest of the bytes passed to the update() method so far.\n" +"\n" +"This may be used to exchange the value safely in email or other non-binary\n" +"environments."); + +#define _HASHLIB_HMAC_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)_hashlib_HMAC_hexdigest, METH_NOARGS, _hashlib_HMAC_hexdigest__doc__}, + +static PyObject * +_hashlib_HMAC_hexdigest_impl(HMACobject *self); + +static PyObject * +_hashlib_HMAC_hexdigest(HMACobject *self, PyObject *Py_UNUSED(ignored)) +{ + return _hashlib_HMAC_hexdigest_impl(self); +} + +#if !defined(LIBRESSL_VERSION_NUMBER) + +PyDoc_STRVAR(_hashlib_get_fips_mode__doc__, +"get_fips_mode($module, /)\n" +"--\n" +"\n" +"Determine the OpenSSL FIPS mode of operation.\n" +"\n" +"For OpenSSL 3.0.0 and newer it returns the state of the default provider\n" +"in the default OSSL context. It\'s not quite the same as FIPS_mode() but good\n" +"enough for unittests.\n" +"\n" +"Effectively any non-zero return value indicates FIPS mode;\n" +"values other than 1 may have additional significance."); + +#define _HASHLIB_GET_FIPS_MODE_METHODDEF \ + {"get_fips_mode", (PyCFunction)_hashlib_get_fips_mode, METH_NOARGS, _hashlib_get_fips_mode__doc__}, + +static int +_hashlib_get_fips_mode_impl(PyObject *module); + +static PyObject * +_hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _hashlib_get_fips_mode_impl(module); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* !defined(LIBRESSL_VERSION_NUMBER) */ + +PyDoc_STRVAR(_hashlib_compare_digest__doc__, +"compare_digest($module, a, b, /)\n" +"--\n" +"\n" +"Return \'a == b\'.\n" +"\n" +"This function uses an approach designed to prevent\n" +"timing analysis, making it appropriate for cryptography.\n" +"\n" +"a and b must both be of the same type: either str (ASCII only),\n" +"or any bytes-like object.\n" +"\n" +"Note: If a and b are of different lengths, or if an error occurs,\n" +"a timing attack could theoretically reveal information about the\n" +"types and lengths of a and b--but not their values."); + +#define _HASHLIB_COMPARE_DIGEST_METHODDEF \ + {"compare_digest", (PyCFunction)(void(*)(void))_hashlib_compare_digest, METH_FASTCALL, _hashlib_compare_digest__doc__}, + +static PyObject * +_hashlib_compare_digest_impl(PyObject *module, PyObject *a, PyObject *b); + +static PyObject * +_hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *a; + PyObject *b; + + if (!_PyArg_CheckPositional("compare_digest", nargs, 2, 2)) { + goto exit; + } + a = args[0]; + b = args[1]; + return_value = _hashlib_compare_digest_impl(module, a, b); + +exit: + return return_value; +} + +#ifndef EVPXOF_DIGEST_METHODDEF + #define EVPXOF_DIGEST_METHODDEF +#endif /* !defined(EVPXOF_DIGEST_METHODDEF) */ + +#ifndef EVPXOF_HEXDIGEST_METHODDEF + #define EVPXOF_HEXDIGEST_METHODDEF +#endif /* !defined(EVPXOF_HEXDIGEST_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHA3_224_METHODDEF + #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHA3_224_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHA3_256_METHODDEF + #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHA3_256_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHA3_384_METHODDEF + #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHA3_384_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHA3_512_METHODDEF + #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHA3_512_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHAKE_128_METHODDEF + #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHAKE_128_METHODDEF) */ + +#ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF + #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF +#endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */ + #ifndef _HASHLIB_SCRYPT_METHODDEF #define _HASHLIB_SCRYPT_METHODDEF #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ - -#ifndef _HASHLIB_GET_FIPS_MODE_METHODDEF - #define _HASHLIB_GET_FIPS_MODE_METHODDEF -#endif /* !defined(_HASHLIB_GET_FIPS_MODE_METHODDEF) */ -/*[clinic end generated code: output=b6b280e46bf0b139 input=a9049054013a1b77]*/ + +#ifndef _HASHLIB_GET_FIPS_MODE_METHODDEF + #define _HASHLIB_GET_FIPS_MODE_METHODDEF +#endif /* !defined(_HASHLIB_GET_FIPS_MODE_METHODDEF) */ +/*[clinic end generated code: output=b6b280e46bf0b139 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_heapqmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_heapqmodule.c.h index 55403706ba..99bf9f0cc1 100644 --- a/contrib/tools/python3/src/Modules/clinic/_heapqmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_heapqmodule.c.h @@ -1,172 +1,172 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_heapq_heappush__doc__, -"heappush($module, heap, item, /)\n" -"--\n" -"\n" -"Push item onto heap, maintaining the heap invariant."); - -#define _HEAPQ_HEAPPUSH_METHODDEF \ - {"heappush", (PyCFunction)(void(*)(void))_heapq_heappush, METH_FASTCALL, _heapq_heappush__doc__}, - -static PyObject * -_heapq_heappush_impl(PyObject *module, PyObject *heap, PyObject *item); - -static PyObject * -_heapq_heappush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *heap; - PyObject *item; - - if (!_PyArg_CheckPositional("heappush", nargs, 2, 2)) { - goto exit; - } - heap = args[0]; - item = args[1]; - return_value = _heapq_heappush_impl(module, heap, item); - -exit: - return return_value; -} - -PyDoc_STRVAR(_heapq_heappop__doc__, -"heappop($module, heap, /)\n" -"--\n" -"\n" -"Pop the smallest item off the heap, maintaining the heap invariant."); - -#define _HEAPQ_HEAPPOP_METHODDEF \ - {"heappop", (PyCFunction)_heapq_heappop, METH_O, _heapq_heappop__doc__}, - -PyDoc_STRVAR(_heapq_heapreplace__doc__, -"heapreplace($module, heap, item, /)\n" -"--\n" -"\n" -"Pop and return the current smallest value, and add the new item.\n" -"\n" -"This is more efficient than heappop() followed by heappush(), and can be\n" -"more appropriate when using a fixed-size heap. Note that the value\n" -"returned may be larger than item! That constrains reasonable uses of\n" -"this routine unless written as part of a conditional replacement:\n" -"\n" -" if item > heap[0]:\n" -" item = heapreplace(heap, item)"); - -#define _HEAPQ_HEAPREPLACE_METHODDEF \ - {"heapreplace", (PyCFunction)(void(*)(void))_heapq_heapreplace, METH_FASTCALL, _heapq_heapreplace__doc__}, - -static PyObject * -_heapq_heapreplace_impl(PyObject *module, PyObject *heap, PyObject *item); - -static PyObject * -_heapq_heapreplace(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *heap; - PyObject *item; - - if (!_PyArg_CheckPositional("heapreplace", nargs, 2, 2)) { - goto exit; - } - heap = args[0]; - item = args[1]; - return_value = _heapq_heapreplace_impl(module, heap, item); - -exit: - return return_value; -} - -PyDoc_STRVAR(_heapq_heappushpop__doc__, -"heappushpop($module, heap, item, /)\n" -"--\n" -"\n" -"Push item on the heap, then pop and return the smallest item from the heap.\n" -"\n" -"The combined action runs more efficiently than heappush() followed by\n" -"a separate call to heappop()."); - -#define _HEAPQ_HEAPPUSHPOP_METHODDEF \ - {"heappushpop", (PyCFunction)(void(*)(void))_heapq_heappushpop, METH_FASTCALL, _heapq_heappushpop__doc__}, - -static PyObject * -_heapq_heappushpop_impl(PyObject *module, PyObject *heap, PyObject *item); - -static PyObject * -_heapq_heappushpop(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *heap; - PyObject *item; - - if (!_PyArg_CheckPositional("heappushpop", nargs, 2, 2)) { - goto exit; - } - heap = args[0]; - item = args[1]; - return_value = _heapq_heappushpop_impl(module, heap, item); - -exit: - return return_value; -} - -PyDoc_STRVAR(_heapq_heapify__doc__, -"heapify($module, heap, /)\n" -"--\n" -"\n" -"Transform list into a heap, in-place, in O(len(heap)) time."); - -#define _HEAPQ_HEAPIFY_METHODDEF \ - {"heapify", (PyCFunction)_heapq_heapify, METH_O, _heapq_heapify__doc__}, - -PyDoc_STRVAR(_heapq__heappop_max__doc__, -"_heappop_max($module, heap, /)\n" -"--\n" -"\n" -"Maxheap variant of heappop."); - -#define _HEAPQ__HEAPPOP_MAX_METHODDEF \ - {"_heappop_max", (PyCFunction)_heapq__heappop_max, METH_O, _heapq__heappop_max__doc__}, - -PyDoc_STRVAR(_heapq__heapreplace_max__doc__, -"_heapreplace_max($module, heap, item, /)\n" -"--\n" -"\n" -"Maxheap variant of heapreplace."); - -#define _HEAPQ__HEAPREPLACE_MAX_METHODDEF \ - {"_heapreplace_max", (PyCFunction)(void(*)(void))_heapq__heapreplace_max, METH_FASTCALL, _heapq__heapreplace_max__doc__}, - -static PyObject * -_heapq__heapreplace_max_impl(PyObject *module, PyObject *heap, - PyObject *item); - -static PyObject * -_heapq__heapreplace_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *heap; - PyObject *item; - - if (!_PyArg_CheckPositional("_heapreplace_max", nargs, 2, 2)) { - goto exit; - } - heap = args[0]; - item = args[1]; - return_value = _heapq__heapreplace_max_impl(module, heap, item); - -exit: - return return_value; -} - -PyDoc_STRVAR(_heapq__heapify_max__doc__, -"_heapify_max($module, heap, /)\n" -"--\n" -"\n" -"Maxheap variant of heapify."); - -#define _HEAPQ__HEAPIFY_MAX_METHODDEF \ - {"_heapify_max", (PyCFunction)_heapq__heapify_max, METH_O, _heapq__heapify_max__doc__}, -/*[clinic end generated code: output=37ef2a3319971c8d input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_heapq_heappush__doc__, +"heappush($module, heap, item, /)\n" +"--\n" +"\n" +"Push item onto heap, maintaining the heap invariant."); + +#define _HEAPQ_HEAPPUSH_METHODDEF \ + {"heappush", (PyCFunction)(void(*)(void))_heapq_heappush, METH_FASTCALL, _heapq_heappush__doc__}, + +static PyObject * +_heapq_heappush_impl(PyObject *module, PyObject *heap, PyObject *item); + +static PyObject * +_heapq_heappush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *heap; + PyObject *item; + + if (!_PyArg_CheckPositional("heappush", nargs, 2, 2)) { + goto exit; + } + heap = args[0]; + item = args[1]; + return_value = _heapq_heappush_impl(module, heap, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(_heapq_heappop__doc__, +"heappop($module, heap, /)\n" +"--\n" +"\n" +"Pop the smallest item off the heap, maintaining the heap invariant."); + +#define _HEAPQ_HEAPPOP_METHODDEF \ + {"heappop", (PyCFunction)_heapq_heappop, METH_O, _heapq_heappop__doc__}, + +PyDoc_STRVAR(_heapq_heapreplace__doc__, +"heapreplace($module, heap, item, /)\n" +"--\n" +"\n" +"Pop and return the current smallest value, and add the new item.\n" +"\n" +"This is more efficient than heappop() followed by heappush(), and can be\n" +"more appropriate when using a fixed-size heap. Note that the value\n" +"returned may be larger than item! That constrains reasonable uses of\n" +"this routine unless written as part of a conditional replacement:\n" +"\n" +" if item > heap[0]:\n" +" item = heapreplace(heap, item)"); + +#define _HEAPQ_HEAPREPLACE_METHODDEF \ + {"heapreplace", (PyCFunction)(void(*)(void))_heapq_heapreplace, METH_FASTCALL, _heapq_heapreplace__doc__}, + +static PyObject * +_heapq_heapreplace_impl(PyObject *module, PyObject *heap, PyObject *item); + +static PyObject * +_heapq_heapreplace(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *heap; + PyObject *item; + + if (!_PyArg_CheckPositional("heapreplace", nargs, 2, 2)) { + goto exit; + } + heap = args[0]; + item = args[1]; + return_value = _heapq_heapreplace_impl(module, heap, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(_heapq_heappushpop__doc__, +"heappushpop($module, heap, item, /)\n" +"--\n" +"\n" +"Push item on the heap, then pop and return the smallest item from the heap.\n" +"\n" +"The combined action runs more efficiently than heappush() followed by\n" +"a separate call to heappop()."); + +#define _HEAPQ_HEAPPUSHPOP_METHODDEF \ + {"heappushpop", (PyCFunction)(void(*)(void))_heapq_heappushpop, METH_FASTCALL, _heapq_heappushpop__doc__}, + +static PyObject * +_heapq_heappushpop_impl(PyObject *module, PyObject *heap, PyObject *item); + +static PyObject * +_heapq_heappushpop(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *heap; + PyObject *item; + + if (!_PyArg_CheckPositional("heappushpop", nargs, 2, 2)) { + goto exit; + } + heap = args[0]; + item = args[1]; + return_value = _heapq_heappushpop_impl(module, heap, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(_heapq_heapify__doc__, +"heapify($module, heap, /)\n" +"--\n" +"\n" +"Transform list into a heap, in-place, in O(len(heap)) time."); + +#define _HEAPQ_HEAPIFY_METHODDEF \ + {"heapify", (PyCFunction)_heapq_heapify, METH_O, _heapq_heapify__doc__}, + +PyDoc_STRVAR(_heapq__heappop_max__doc__, +"_heappop_max($module, heap, /)\n" +"--\n" +"\n" +"Maxheap variant of heappop."); + +#define _HEAPQ__HEAPPOP_MAX_METHODDEF \ + {"_heappop_max", (PyCFunction)_heapq__heappop_max, METH_O, _heapq__heappop_max__doc__}, + +PyDoc_STRVAR(_heapq__heapreplace_max__doc__, +"_heapreplace_max($module, heap, item, /)\n" +"--\n" +"\n" +"Maxheap variant of heapreplace."); + +#define _HEAPQ__HEAPREPLACE_MAX_METHODDEF \ + {"_heapreplace_max", (PyCFunction)(void(*)(void))_heapq__heapreplace_max, METH_FASTCALL, _heapq__heapreplace_max__doc__}, + +static PyObject * +_heapq__heapreplace_max_impl(PyObject *module, PyObject *heap, + PyObject *item); + +static PyObject * +_heapq__heapreplace_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *heap; + PyObject *item; + + if (!_PyArg_CheckPositional("_heapreplace_max", nargs, 2, 2)) { + goto exit; + } + heap = args[0]; + item = args[1]; + return_value = _heapq__heapreplace_max_impl(module, heap, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(_heapq__heapify_max__doc__, +"_heapify_max($module, heap, /)\n" +"--\n" +"\n" +"Maxheap variant of heapify."); + +#define _HEAPQ__HEAPIFY_MAX_METHODDEF \ + {"_heapify_max", (PyCFunction)_heapq__heapify_max, METH_O, _heapq__heapify_max__doc__}, +/*[clinic end generated code: output=37ef2a3319971c8d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_lzmamodule.c.h b/contrib/tools/python3/src/Modules/clinic/_lzmamodule.c.h index 82ef4d517d..edfdd9fff0 100644 --- a/contrib/tools/python3/src/Modules/clinic/_lzmamodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_lzmamodule.c.h @@ -25,13 +25,13 @@ _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _lzma_LZMACompressor_compress_impl(self, &data); exit: @@ -85,7 +85,7 @@ PyDoc_STRVAR(_lzma_LZMADecompressor_decompress__doc__, "the unused_data attribute."); #define _LZMA_LZMADECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))_lzma_LZMADecompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, + {"decompress", (PyCFunction)(void(*)(void))_lzma_LZMADecompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, static PyObject * _lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data, @@ -96,44 +96,44 @@ _lzma_LZMADecompressor_decompress(Decompressor *self, PyObject *const *args, Py_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "max_length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - max_length = ival; - } -skip_optional_pos: + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + max_length = ival; + } +skip_optional_pos: return_value = _lzma_LZMADecompressor_decompress_impl(self, &data, max_length); exit: @@ -177,44 +177,44 @@ _lzma_LZMADecompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs { int return_value = -1; static const char * const _keywords[] = {"format", "memlimit", "filters", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "LZMADecompressor", 0}; - PyObject *argsbuf[3]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "LZMADecompressor", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; int format = FORMAT_AUTO; PyObject *memlimit = Py_None; PyObject *filters = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 3, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 3, 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; - } - format = _PyLong_AsInt(fastargs[0]); - if (format == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[1]) { - memlimit = fastargs[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - filters = fastargs[2]; -skip_optional_pos: + 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; + } + format = _PyLong_AsInt(fastargs[0]); + if (format == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[1]) { + memlimit = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + filters = fastargs[2]; +skip_optional_pos: return_value = _lzma_LZMADecompressor___init___impl((Decompressor *)self, format, memlimit, filters); exit: @@ -241,15 +241,15 @@ _lzma_is_check_supported(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int check_id; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - check_id = _PyLong_AsInt(arg); - if (check_id == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + check_id = _PyLong_AsInt(arg); + if (check_id == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _lzma_is_check_supported_impl(module, check_id); exit: @@ -276,7 +276,7 @@ _lzma__encode_filter_properties(PyObject *module, PyObject *arg) PyObject *return_value = NULL; lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL}; - if (!lzma_filter_converter(arg, &filter)) { + if (!lzma_filter_converter(arg, &filter)) { goto exit; } return_value = _lzma__encode_filter_properties_impl(module, filter); @@ -298,7 +298,7 @@ PyDoc_STRVAR(_lzma__decode_filter_properties__doc__, "The result does not include the filter ID itself, only the options."); #define _LZMA__DECODE_FILTER_PROPERTIES_METHODDEF \ - {"_decode_filter_properties", (PyCFunction)(void(*)(void))_lzma__decode_filter_properties, METH_FASTCALL, _lzma__decode_filter_properties__doc__}, + {"_decode_filter_properties", (PyCFunction)(void(*)(void))_lzma__decode_filter_properties, METH_FASTCALL, _lzma__decode_filter_properties__doc__}, static PyObject * _lzma__decode_filter_properties_impl(PyObject *module, lzma_vli filter_id, @@ -311,19 +311,19 @@ _lzma__decode_filter_properties(PyObject *module, PyObject *const *args, Py_ssiz lzma_vli filter_id; Py_buffer encoded_props = {NULL, NULL}; - if (!_PyArg_CheckPositional("_decode_filter_properties", nargs, 2, 2)) { - goto exit; - } - if (!lzma_vli_converter(args[0], &filter_id)) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &encoded_props, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&encoded_props, 'C')) { - _PyArg_BadArgument("_decode_filter_properties", "argument 2", "contiguous buffer", args[1]); + if (!_PyArg_CheckPositional("_decode_filter_properties", nargs, 2, 2)) { goto exit; } + if (!lzma_vli_converter(args[0], &filter_id)) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &encoded_props, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&encoded_props, 'C')) { + _PyArg_BadArgument("_decode_filter_properties", "argument 2", "contiguous buffer", args[1]); + goto exit; + } return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props); exit: @@ -334,4 +334,4 @@ exit: return return_value; } -/*[clinic end generated code: output=f7477a10e86a717d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f7477a10e86a717d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_opcode.c.h b/contrib/tools/python3/src/Modules/clinic/_opcode.c.h index 777701ff14..906e0d9ace 100644 --- a/contrib/tools/python3/src/Modules/clinic/_opcode.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_opcode.c.h @@ -3,56 +3,56 @@ preserve [clinic start generated code]*/ PyDoc_STRVAR(_opcode_stack_effect__doc__, -"stack_effect($module, opcode, oparg=None, /, *, jump=None)\n" +"stack_effect($module, opcode, oparg=None, /, *, jump=None)\n" "--\n" "\n" "Compute the stack effect of the opcode."); #define _OPCODE_STACK_EFFECT_METHODDEF \ - {"stack_effect", (PyCFunction)(void(*)(void))_opcode_stack_effect, METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__}, + {"stack_effect", (PyCFunction)(void(*)(void))_opcode_stack_effect, METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__}, static int -_opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg, - PyObject *jump); +_opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg, + PyObject *jump); static PyObject * -_opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +_opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "", "jump", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "stack_effect", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"", "", "jump", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "stack_effect", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; int opcode; PyObject *oparg = Py_None; - PyObject *jump = Py_None; + PyObject *jump = Py_None; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - opcode = _PyLong_AsInt(args[0]); - if (opcode == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 2) { - goto skip_optional_posonly; - } - noptargs--; - oparg = args[1]; -skip_optional_posonly: - if (!noptargs) { - goto skip_optional_kwonly; - } - jump = args[2]; -skip_optional_kwonly: - _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump); + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + opcode = _PyLong_AsInt(args[0]); + if (opcode == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + oparg = args[1]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + jump = args[2]; +skip_optional_kwonly: + _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; } @@ -61,4 +61,4 @@ skip_optional_kwonly: exit: return return_value; } -/*[clinic end generated code: output=7bc08f2835b2cf89 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7bc08f2835b2cf89 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_operator.c.h b/contrib/tools/python3/src/Modules/clinic/_operator.c.h index 0e39f3b77a..39ecfae970 100644 --- a/contrib/tools/python3/src/Modules/clinic/_operator.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_operator.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(_operator_add__doc__, "Same as a + b."); #define _OPERATOR_ADD_METHODDEF \ - {"add", (PyCFunction)(void(*)(void))_operator_add, METH_FASTCALL, _operator_add__doc__}, + {"add", (PyCFunction)(void(*)(void))_operator_add, METH_FASTCALL, _operator_add__doc__}, static PyObject * _operator_add_impl(PyObject *module, PyObject *a, PyObject *b); @@ -49,11 +49,11 @@ _operator_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("add", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("add", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_add_impl(module, a, b); exit: @@ -67,7 +67,7 @@ PyDoc_STRVAR(_operator_sub__doc__, "Same as a - b."); #define _OPERATOR_SUB_METHODDEF \ - {"sub", (PyCFunction)(void(*)(void))_operator_sub, METH_FASTCALL, _operator_sub__doc__}, + {"sub", (PyCFunction)(void(*)(void))_operator_sub, METH_FASTCALL, _operator_sub__doc__}, static PyObject * _operator_sub_impl(PyObject *module, PyObject *a, PyObject *b); @@ -79,11 +79,11 @@ _operator_sub(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("sub", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("sub", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_sub_impl(module, a, b); exit: @@ -97,7 +97,7 @@ PyDoc_STRVAR(_operator_mul__doc__, "Same as a * b."); #define _OPERATOR_MUL_METHODDEF \ - {"mul", (PyCFunction)(void(*)(void))_operator_mul, METH_FASTCALL, _operator_mul__doc__}, + {"mul", (PyCFunction)(void(*)(void))_operator_mul, METH_FASTCALL, _operator_mul__doc__}, static PyObject * _operator_mul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -109,11 +109,11 @@ _operator_mul(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("mul", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("mul", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_mul_impl(module, a, b); exit: @@ -127,7 +127,7 @@ PyDoc_STRVAR(_operator_matmul__doc__, "Same as a @ b."); #define _OPERATOR_MATMUL_METHODDEF \ - {"matmul", (PyCFunction)(void(*)(void))_operator_matmul, METH_FASTCALL, _operator_matmul__doc__}, + {"matmul", (PyCFunction)(void(*)(void))_operator_matmul, METH_FASTCALL, _operator_matmul__doc__}, static PyObject * _operator_matmul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -139,11 +139,11 @@ _operator_matmul(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("matmul", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("matmul", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_matmul_impl(module, a, b); exit: @@ -157,7 +157,7 @@ PyDoc_STRVAR(_operator_floordiv__doc__, "Same as a // b."); #define _OPERATOR_FLOORDIV_METHODDEF \ - {"floordiv", (PyCFunction)(void(*)(void))_operator_floordiv, METH_FASTCALL, _operator_floordiv__doc__}, + {"floordiv", (PyCFunction)(void(*)(void))_operator_floordiv, METH_FASTCALL, _operator_floordiv__doc__}, static PyObject * _operator_floordiv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -169,11 +169,11 @@ _operator_floordiv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("floordiv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("floordiv", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_floordiv_impl(module, a, b); exit: @@ -187,7 +187,7 @@ PyDoc_STRVAR(_operator_truediv__doc__, "Same as a / b."); #define _OPERATOR_TRUEDIV_METHODDEF \ - {"truediv", (PyCFunction)(void(*)(void))_operator_truediv, METH_FASTCALL, _operator_truediv__doc__}, + {"truediv", (PyCFunction)(void(*)(void))_operator_truediv, METH_FASTCALL, _operator_truediv__doc__}, static PyObject * _operator_truediv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -199,11 +199,11 @@ _operator_truediv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("truediv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("truediv", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_truediv_impl(module, a, b); exit: @@ -217,7 +217,7 @@ PyDoc_STRVAR(_operator_mod__doc__, "Same as a % b."); #define _OPERATOR_MOD_METHODDEF \ - {"mod", (PyCFunction)(void(*)(void))_operator_mod, METH_FASTCALL, _operator_mod__doc__}, + {"mod", (PyCFunction)(void(*)(void))_operator_mod, METH_FASTCALL, _operator_mod__doc__}, static PyObject * _operator_mod_impl(PyObject *module, PyObject *a, PyObject *b); @@ -229,11 +229,11 @@ _operator_mod(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("mod", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("mod", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_mod_impl(module, a, b); exit: @@ -292,7 +292,7 @@ PyDoc_STRVAR(_operator_lshift__doc__, "Same as a << b."); #define _OPERATOR_LSHIFT_METHODDEF \ - {"lshift", (PyCFunction)(void(*)(void))_operator_lshift, METH_FASTCALL, _operator_lshift__doc__}, + {"lshift", (PyCFunction)(void(*)(void))_operator_lshift, METH_FASTCALL, _operator_lshift__doc__}, static PyObject * _operator_lshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -304,11 +304,11 @@ _operator_lshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("lshift", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("lshift", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_lshift_impl(module, a, b); exit: @@ -322,7 +322,7 @@ PyDoc_STRVAR(_operator_rshift__doc__, "Same as a >> b."); #define _OPERATOR_RSHIFT_METHODDEF \ - {"rshift", (PyCFunction)(void(*)(void))_operator_rshift, METH_FASTCALL, _operator_rshift__doc__}, + {"rshift", (PyCFunction)(void(*)(void))_operator_rshift, METH_FASTCALL, _operator_rshift__doc__}, static PyObject * _operator_rshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -334,11 +334,11 @@ _operator_rshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("rshift", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("rshift", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_rshift_impl(module, a, b); exit: @@ -380,7 +380,7 @@ PyDoc_STRVAR(_operator_and___doc__, "Same as a & b."); #define _OPERATOR_AND__METHODDEF \ - {"and_", (PyCFunction)(void(*)(void))_operator_and_, METH_FASTCALL, _operator_and___doc__}, + {"and_", (PyCFunction)(void(*)(void))_operator_and_, METH_FASTCALL, _operator_and___doc__}, static PyObject * _operator_and__impl(PyObject *module, PyObject *a, PyObject *b); @@ -392,11 +392,11 @@ _operator_and_(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("and_", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("and_", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_and__impl(module, a, b); exit: @@ -410,7 +410,7 @@ PyDoc_STRVAR(_operator_xor__doc__, "Same as a ^ b."); #define _OPERATOR_XOR_METHODDEF \ - {"xor", (PyCFunction)(void(*)(void))_operator_xor, METH_FASTCALL, _operator_xor__doc__}, + {"xor", (PyCFunction)(void(*)(void))_operator_xor, METH_FASTCALL, _operator_xor__doc__}, static PyObject * _operator_xor_impl(PyObject *module, PyObject *a, PyObject *b); @@ -422,11 +422,11 @@ _operator_xor(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("xor", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("xor", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_xor_impl(module, a, b); exit: @@ -440,7 +440,7 @@ PyDoc_STRVAR(_operator_or___doc__, "Same as a | b."); #define _OPERATOR_OR__METHODDEF \ - {"or_", (PyCFunction)(void(*)(void))_operator_or_, METH_FASTCALL, _operator_or___doc__}, + {"or_", (PyCFunction)(void(*)(void))_operator_or_, METH_FASTCALL, _operator_or___doc__}, static PyObject * _operator_or__impl(PyObject *module, PyObject *a, PyObject *b); @@ -452,11 +452,11 @@ _operator_or_(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("or_", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("or_", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_or__impl(module, a, b); exit: @@ -470,7 +470,7 @@ PyDoc_STRVAR(_operator_iadd__doc__, "Same as a += b."); #define _OPERATOR_IADD_METHODDEF \ - {"iadd", (PyCFunction)(void(*)(void))_operator_iadd, METH_FASTCALL, _operator_iadd__doc__}, + {"iadd", (PyCFunction)(void(*)(void))_operator_iadd, METH_FASTCALL, _operator_iadd__doc__}, static PyObject * _operator_iadd_impl(PyObject *module, PyObject *a, PyObject *b); @@ -482,11 +482,11 @@ _operator_iadd(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("iadd", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("iadd", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_iadd_impl(module, a, b); exit: @@ -500,7 +500,7 @@ PyDoc_STRVAR(_operator_isub__doc__, "Same as a -= b."); #define _OPERATOR_ISUB_METHODDEF \ - {"isub", (PyCFunction)(void(*)(void))_operator_isub, METH_FASTCALL, _operator_isub__doc__}, + {"isub", (PyCFunction)(void(*)(void))_operator_isub, METH_FASTCALL, _operator_isub__doc__}, static PyObject * _operator_isub_impl(PyObject *module, PyObject *a, PyObject *b); @@ -512,11 +512,11 @@ _operator_isub(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("isub", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("isub", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_isub_impl(module, a, b); exit: @@ -530,7 +530,7 @@ PyDoc_STRVAR(_operator_imul__doc__, "Same as a *= b."); #define _OPERATOR_IMUL_METHODDEF \ - {"imul", (PyCFunction)(void(*)(void))_operator_imul, METH_FASTCALL, _operator_imul__doc__}, + {"imul", (PyCFunction)(void(*)(void))_operator_imul, METH_FASTCALL, _operator_imul__doc__}, static PyObject * _operator_imul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -542,11 +542,11 @@ _operator_imul(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("imul", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("imul", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_imul_impl(module, a, b); exit: @@ -560,7 +560,7 @@ PyDoc_STRVAR(_operator_imatmul__doc__, "Same as a @= b."); #define _OPERATOR_IMATMUL_METHODDEF \ - {"imatmul", (PyCFunction)(void(*)(void))_operator_imatmul, METH_FASTCALL, _operator_imatmul__doc__}, + {"imatmul", (PyCFunction)(void(*)(void))_operator_imatmul, METH_FASTCALL, _operator_imatmul__doc__}, static PyObject * _operator_imatmul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -572,11 +572,11 @@ _operator_imatmul(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("imatmul", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("imatmul", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_imatmul_impl(module, a, b); exit: @@ -590,7 +590,7 @@ PyDoc_STRVAR(_operator_ifloordiv__doc__, "Same as a //= b."); #define _OPERATOR_IFLOORDIV_METHODDEF \ - {"ifloordiv", (PyCFunction)(void(*)(void))_operator_ifloordiv, METH_FASTCALL, _operator_ifloordiv__doc__}, + {"ifloordiv", (PyCFunction)(void(*)(void))_operator_ifloordiv, METH_FASTCALL, _operator_ifloordiv__doc__}, static PyObject * _operator_ifloordiv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -602,11 +602,11 @@ _operator_ifloordiv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ifloordiv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ifloordiv", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ifloordiv_impl(module, a, b); exit: @@ -620,7 +620,7 @@ PyDoc_STRVAR(_operator_itruediv__doc__, "Same as a /= b."); #define _OPERATOR_ITRUEDIV_METHODDEF \ - {"itruediv", (PyCFunction)(void(*)(void))_operator_itruediv, METH_FASTCALL, _operator_itruediv__doc__}, + {"itruediv", (PyCFunction)(void(*)(void))_operator_itruediv, METH_FASTCALL, _operator_itruediv__doc__}, static PyObject * _operator_itruediv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -632,11 +632,11 @@ _operator_itruediv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("itruediv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("itruediv", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_itruediv_impl(module, a, b); exit: @@ -650,7 +650,7 @@ PyDoc_STRVAR(_operator_imod__doc__, "Same as a %= b."); #define _OPERATOR_IMOD_METHODDEF \ - {"imod", (PyCFunction)(void(*)(void))_operator_imod, METH_FASTCALL, _operator_imod__doc__}, + {"imod", (PyCFunction)(void(*)(void))_operator_imod, METH_FASTCALL, _operator_imod__doc__}, static PyObject * _operator_imod_impl(PyObject *module, PyObject *a, PyObject *b); @@ -662,11 +662,11 @@ _operator_imod(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("imod", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("imod", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_imod_impl(module, a, b); exit: @@ -680,7 +680,7 @@ PyDoc_STRVAR(_operator_ilshift__doc__, "Same as a <<= b."); #define _OPERATOR_ILSHIFT_METHODDEF \ - {"ilshift", (PyCFunction)(void(*)(void))_operator_ilshift, METH_FASTCALL, _operator_ilshift__doc__}, + {"ilshift", (PyCFunction)(void(*)(void))_operator_ilshift, METH_FASTCALL, _operator_ilshift__doc__}, static PyObject * _operator_ilshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -692,11 +692,11 @@ _operator_ilshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ilshift", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ilshift", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ilshift_impl(module, a, b); exit: @@ -710,7 +710,7 @@ PyDoc_STRVAR(_operator_irshift__doc__, "Same as a >>= b."); #define _OPERATOR_IRSHIFT_METHODDEF \ - {"irshift", (PyCFunction)(void(*)(void))_operator_irshift, METH_FASTCALL, _operator_irshift__doc__}, + {"irshift", (PyCFunction)(void(*)(void))_operator_irshift, METH_FASTCALL, _operator_irshift__doc__}, static PyObject * _operator_irshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -722,11 +722,11 @@ _operator_irshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("irshift", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("irshift", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_irshift_impl(module, a, b); exit: @@ -740,7 +740,7 @@ PyDoc_STRVAR(_operator_iand__doc__, "Same as a &= b."); #define _OPERATOR_IAND_METHODDEF \ - {"iand", (PyCFunction)(void(*)(void))_operator_iand, METH_FASTCALL, _operator_iand__doc__}, + {"iand", (PyCFunction)(void(*)(void))_operator_iand, METH_FASTCALL, _operator_iand__doc__}, static PyObject * _operator_iand_impl(PyObject *module, PyObject *a, PyObject *b); @@ -752,11 +752,11 @@ _operator_iand(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("iand", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("iand", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_iand_impl(module, a, b); exit: @@ -770,7 +770,7 @@ PyDoc_STRVAR(_operator_ixor__doc__, "Same as a ^= b."); #define _OPERATOR_IXOR_METHODDEF \ - {"ixor", (PyCFunction)(void(*)(void))_operator_ixor, METH_FASTCALL, _operator_ixor__doc__}, + {"ixor", (PyCFunction)(void(*)(void))_operator_ixor, METH_FASTCALL, _operator_ixor__doc__}, static PyObject * _operator_ixor_impl(PyObject *module, PyObject *a, PyObject *b); @@ -782,11 +782,11 @@ _operator_ixor(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ixor", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ixor", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ixor_impl(module, a, b); exit: @@ -800,7 +800,7 @@ PyDoc_STRVAR(_operator_ior__doc__, "Same as a |= b."); #define _OPERATOR_IOR_METHODDEF \ - {"ior", (PyCFunction)(void(*)(void))_operator_ior, METH_FASTCALL, _operator_ior__doc__}, + {"ior", (PyCFunction)(void(*)(void))_operator_ior, METH_FASTCALL, _operator_ior__doc__}, static PyObject * _operator_ior_impl(PyObject *module, PyObject *a, PyObject *b); @@ -812,11 +812,11 @@ _operator_ior(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ior", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ior", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ior_impl(module, a, b); exit: @@ -830,7 +830,7 @@ PyDoc_STRVAR(_operator_concat__doc__, "Same as a + b, for a and b sequences."); #define _OPERATOR_CONCAT_METHODDEF \ - {"concat", (PyCFunction)(void(*)(void))_operator_concat, METH_FASTCALL, _operator_concat__doc__}, + {"concat", (PyCFunction)(void(*)(void))_operator_concat, METH_FASTCALL, _operator_concat__doc__}, static PyObject * _operator_concat_impl(PyObject *module, PyObject *a, PyObject *b); @@ -842,11 +842,11 @@ _operator_concat(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("concat", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("concat", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_concat_impl(module, a, b); exit: @@ -860,7 +860,7 @@ PyDoc_STRVAR(_operator_iconcat__doc__, "Same as a += b, for a and b sequences."); #define _OPERATOR_ICONCAT_METHODDEF \ - {"iconcat", (PyCFunction)(void(*)(void))_operator_iconcat, METH_FASTCALL, _operator_iconcat__doc__}, + {"iconcat", (PyCFunction)(void(*)(void))_operator_iconcat, METH_FASTCALL, _operator_iconcat__doc__}, static PyObject * _operator_iconcat_impl(PyObject *module, PyObject *a, PyObject *b); @@ -872,11 +872,11 @@ _operator_iconcat(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("iconcat", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("iconcat", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_iconcat_impl(module, a, b); exit: @@ -890,7 +890,7 @@ PyDoc_STRVAR(_operator_contains__doc__, "Same as b in a (note reversed operands)."); #define _OPERATOR_CONTAINS_METHODDEF \ - {"contains", (PyCFunction)(void(*)(void))_operator_contains, METH_FASTCALL, _operator_contains__doc__}, + {"contains", (PyCFunction)(void(*)(void))_operator_contains, METH_FASTCALL, _operator_contains__doc__}, static int _operator_contains_impl(PyObject *module, PyObject *a, PyObject *b); @@ -903,11 +903,11 @@ _operator_contains(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *b; int _return_value; - if (!_PyArg_CheckPositional("contains", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("contains", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; _return_value = _operator_contains_impl(module, a, b); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -925,7 +925,7 @@ PyDoc_STRVAR(_operator_indexOf__doc__, "Return the first index of b in a."); #define _OPERATOR_INDEXOF_METHODDEF \ - {"indexOf", (PyCFunction)(void(*)(void))_operator_indexOf, METH_FASTCALL, _operator_indexOf__doc__}, + {"indexOf", (PyCFunction)(void(*)(void))_operator_indexOf, METH_FASTCALL, _operator_indexOf__doc__}, static Py_ssize_t _operator_indexOf_impl(PyObject *module, PyObject *a, PyObject *b); @@ -938,11 +938,11 @@ _operator_indexOf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *b; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("indexOf", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("indexOf", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; _return_value = _operator_indexOf_impl(module, a, b); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -957,10 +957,10 @@ PyDoc_STRVAR(_operator_countOf__doc__, "countOf($module, a, b, /)\n" "--\n" "\n" -"Return the number of items in a which are, or which equal, b."); +"Return the number of items in a which are, or which equal, b."); #define _OPERATOR_COUNTOF_METHODDEF \ - {"countOf", (PyCFunction)(void(*)(void))_operator_countOf, METH_FASTCALL, _operator_countOf__doc__}, + {"countOf", (PyCFunction)(void(*)(void))_operator_countOf, METH_FASTCALL, _operator_countOf__doc__}, static Py_ssize_t _operator_countOf_impl(PyObject *module, PyObject *a, PyObject *b); @@ -973,11 +973,11 @@ _operator_countOf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *b; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("countOf", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("countOf", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; _return_value = _operator_countOf_impl(module, a, b); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -995,7 +995,7 @@ PyDoc_STRVAR(_operator_getitem__doc__, "Same as a[b]."); #define _OPERATOR_GETITEM_METHODDEF \ - {"getitem", (PyCFunction)(void(*)(void))_operator_getitem, METH_FASTCALL, _operator_getitem__doc__}, + {"getitem", (PyCFunction)(void(*)(void))_operator_getitem, METH_FASTCALL, _operator_getitem__doc__}, static PyObject * _operator_getitem_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1007,11 +1007,11 @@ _operator_getitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("getitem", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("getitem", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_getitem_impl(module, a, b); exit: @@ -1025,7 +1025,7 @@ PyDoc_STRVAR(_operator_setitem__doc__, "Same as a[b] = c."); #define _OPERATOR_SETITEM_METHODDEF \ - {"setitem", (PyCFunction)(void(*)(void))_operator_setitem, METH_FASTCALL, _operator_setitem__doc__}, + {"setitem", (PyCFunction)(void(*)(void))_operator_setitem, METH_FASTCALL, _operator_setitem__doc__}, static PyObject * _operator_setitem_impl(PyObject *module, PyObject *a, PyObject *b, @@ -1039,12 +1039,12 @@ _operator_setitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *b; PyObject *c; - if (!_PyArg_CheckPositional("setitem", nargs, 3, 3)) { + if (!_PyArg_CheckPositional("setitem", nargs, 3, 3)) { goto exit; } - a = args[0]; - b = args[1]; - c = args[2]; + a = args[0]; + b = args[1]; + c = args[2]; return_value = _operator_setitem_impl(module, a, b, c); exit: @@ -1058,7 +1058,7 @@ PyDoc_STRVAR(_operator_delitem__doc__, "Same as del a[b]."); #define _OPERATOR_DELITEM_METHODDEF \ - {"delitem", (PyCFunction)(void(*)(void))_operator_delitem, METH_FASTCALL, _operator_delitem__doc__}, + {"delitem", (PyCFunction)(void(*)(void))_operator_delitem, METH_FASTCALL, _operator_delitem__doc__}, static PyObject * _operator_delitem_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1070,11 +1070,11 @@ _operator_delitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("delitem", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("delitem", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_delitem_impl(module, a, b); exit: @@ -1088,7 +1088,7 @@ PyDoc_STRVAR(_operator_eq__doc__, "Same as a == b."); #define _OPERATOR_EQ_METHODDEF \ - {"eq", (PyCFunction)(void(*)(void))_operator_eq, METH_FASTCALL, _operator_eq__doc__}, + {"eq", (PyCFunction)(void(*)(void))_operator_eq, METH_FASTCALL, _operator_eq__doc__}, static PyObject * _operator_eq_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1100,11 +1100,11 @@ _operator_eq(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("eq", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("eq", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_eq_impl(module, a, b); exit: @@ -1118,7 +1118,7 @@ PyDoc_STRVAR(_operator_ne__doc__, "Same as a != b."); #define _OPERATOR_NE_METHODDEF \ - {"ne", (PyCFunction)(void(*)(void))_operator_ne, METH_FASTCALL, _operator_ne__doc__}, + {"ne", (PyCFunction)(void(*)(void))_operator_ne, METH_FASTCALL, _operator_ne__doc__}, static PyObject * _operator_ne_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1130,11 +1130,11 @@ _operator_ne(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ne", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ne", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ne_impl(module, a, b); exit: @@ -1148,7 +1148,7 @@ PyDoc_STRVAR(_operator_lt__doc__, "Same as a < b."); #define _OPERATOR_LT_METHODDEF \ - {"lt", (PyCFunction)(void(*)(void))_operator_lt, METH_FASTCALL, _operator_lt__doc__}, + {"lt", (PyCFunction)(void(*)(void))_operator_lt, METH_FASTCALL, _operator_lt__doc__}, static PyObject * _operator_lt_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1160,11 +1160,11 @@ _operator_lt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("lt", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("lt", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_lt_impl(module, a, b); exit: @@ -1178,7 +1178,7 @@ PyDoc_STRVAR(_operator_le__doc__, "Same as a <= b."); #define _OPERATOR_LE_METHODDEF \ - {"le", (PyCFunction)(void(*)(void))_operator_le, METH_FASTCALL, _operator_le__doc__}, + {"le", (PyCFunction)(void(*)(void))_operator_le, METH_FASTCALL, _operator_le__doc__}, static PyObject * _operator_le_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1190,11 +1190,11 @@ _operator_le(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("le", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("le", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_le_impl(module, a, b); exit: @@ -1208,7 +1208,7 @@ PyDoc_STRVAR(_operator_gt__doc__, "Same as a > b."); #define _OPERATOR_GT_METHODDEF \ - {"gt", (PyCFunction)(void(*)(void))_operator_gt, METH_FASTCALL, _operator_gt__doc__}, + {"gt", (PyCFunction)(void(*)(void))_operator_gt, METH_FASTCALL, _operator_gt__doc__}, static PyObject * _operator_gt_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1220,11 +1220,11 @@ _operator_gt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("gt", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("gt", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_gt_impl(module, a, b); exit: @@ -1238,7 +1238,7 @@ PyDoc_STRVAR(_operator_ge__doc__, "Same as a >= b."); #define _OPERATOR_GE_METHODDEF \ - {"ge", (PyCFunction)(void(*)(void))_operator_ge, METH_FASTCALL, _operator_ge__doc__}, + {"ge", (PyCFunction)(void(*)(void))_operator_ge, METH_FASTCALL, _operator_ge__doc__}, static PyObject * _operator_ge_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1250,11 +1250,11 @@ _operator_ge(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ge", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ge", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ge_impl(module, a, b); exit: @@ -1268,7 +1268,7 @@ PyDoc_STRVAR(_operator_pow__doc__, "Same as a ** b."); #define _OPERATOR_POW_METHODDEF \ - {"pow", (PyCFunction)(void(*)(void))_operator_pow, METH_FASTCALL, _operator_pow__doc__}, + {"pow", (PyCFunction)(void(*)(void))_operator_pow, METH_FASTCALL, _operator_pow__doc__}, static PyObject * _operator_pow_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1280,11 +1280,11 @@ _operator_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_pow_impl(module, a, b); exit: @@ -1298,7 +1298,7 @@ PyDoc_STRVAR(_operator_ipow__doc__, "Same as a **= b."); #define _OPERATOR_IPOW_METHODDEF \ - {"ipow", (PyCFunction)(void(*)(void))_operator_ipow, METH_FASTCALL, _operator_ipow__doc__}, + {"ipow", (PyCFunction)(void(*)(void))_operator_ipow, METH_FASTCALL, _operator_ipow__doc__}, static PyObject * _operator_ipow_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1310,11 +1310,11 @@ _operator_ipow(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("ipow", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ipow", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_ipow_impl(module, a, b); exit: @@ -1337,7 +1337,7 @@ PyDoc_STRVAR(_operator_is___doc__, "Same as a is b."); #define _OPERATOR_IS__METHODDEF \ - {"is_", (PyCFunction)(void(*)(void))_operator_is_, METH_FASTCALL, _operator_is___doc__}, + {"is_", (PyCFunction)(void(*)(void))_operator_is_, METH_FASTCALL, _operator_is___doc__}, static PyObject * _operator_is__impl(PyObject *module, PyObject *a, PyObject *b); @@ -1349,11 +1349,11 @@ _operator_is_(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("is_", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("is_", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_is__impl(module, a, b); exit: @@ -1367,7 +1367,7 @@ PyDoc_STRVAR(_operator_is_not__doc__, "Same as a is not b."); #define _OPERATOR_IS_NOT_METHODDEF \ - {"is_not", (PyCFunction)(void(*)(void))_operator_is_not, METH_FASTCALL, _operator_is_not__doc__}, + {"is_not", (PyCFunction)(void(*)(void))_operator_is_not, METH_FASTCALL, _operator_is_not__doc__}, static PyObject * _operator_is_not_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1379,11 +1379,11 @@ _operator_is_not(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("is_not", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("is_not", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator_is_not_impl(module, a, b); exit: @@ -1403,7 +1403,7 @@ PyDoc_STRVAR(_operator_length_hint__doc__, "The result will be an integer >= 0."); #define _OPERATOR_LENGTH_HINT_METHODDEF \ - {"length_hint", (PyCFunction)(void(*)(void))_operator_length_hint, METH_FASTCALL, _operator_length_hint__doc__}, + {"length_hint", (PyCFunction)(void(*)(void))_operator_length_hint, METH_FASTCALL, _operator_length_hint__doc__}, static Py_ssize_t _operator_length_hint_impl(PyObject *module, PyObject *obj, @@ -1417,31 +1417,31 @@ _operator_length_hint(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t default_value = 0; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("length_hint", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("length_hint", nargs, 1, 2)) { goto exit; } - obj = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - default_value = ival; - } -skip_optional: + obj = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + default_value = ival; + } +skip_optional: _return_value = _operator_length_hint_impl(module, obj, default_value); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -1469,7 +1469,7 @@ PyDoc_STRVAR(_operator__compare_digest__doc__, "types and lengths of a and b--but not their values."); #define _OPERATOR__COMPARE_DIGEST_METHODDEF \ - {"_compare_digest", (PyCFunction)(void(*)(void))_operator__compare_digest, METH_FASTCALL, _operator__compare_digest__doc__}, + {"_compare_digest", (PyCFunction)(void(*)(void))_operator__compare_digest, METH_FASTCALL, _operator__compare_digest__doc__}, static PyObject * _operator__compare_digest_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1481,14 +1481,14 @@ _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t na PyObject *a; PyObject *b; - if (!_PyArg_CheckPositional("_compare_digest", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("_compare_digest", nargs, 2, 2)) { goto exit; } - a = args[0]; - b = args[1]; + a = args[0]; + b = args[1]; return_value = _operator__compare_digest_impl(module, a, b); exit: return return_value; } -/*[clinic end generated code: output=ed2bc172e42320d8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ed2bc172e42320d8 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_pickle.c.h b/contrib/tools/python3/src/Modules/clinic/_pickle.c.h index 136524b6a7..715be653a3 100644 --- a/contrib/tools/python3/src/Modules/clinic/_pickle.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_pickle.c.h @@ -63,15 +63,15 @@ exit: } PyDoc_STRVAR(_pickle_Pickler___init____doc__, -"Pickler(file, protocol=None, fix_imports=True, buffer_callback=None)\n" +"Pickler(file, protocol=None, fix_imports=True, buffer_callback=None)\n" "--\n" "\n" "This takes a binary file for writing a pickle data stream.\n" "\n" "The optional *protocol* argument tells the pickler to use the given\n" -"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" -"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" -"with previous versions.\n" +"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" +"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" +"with previous versions.\n" "\n" "Specifying a negative protocol version selects the highest protocol\n" "version supported. The higher the protocol used, the more recent the\n" @@ -84,65 +84,65 @@ PyDoc_STRVAR(_pickle_Pickler___init____doc__, "\n" "If *fix_imports* is True and protocol is less than 3, pickle will try\n" "to map the new Python 3 names to the old module names used in Python\n" -"2, so that the pickle data stream is readable with Python 2.\n" -"\n" -"If *buffer_callback* is None (the default), buffer views are\n" -"serialized into *file* as part of the pickle stream.\n" -"\n" -"If *buffer_callback* is not None, then it can be called any number\n" -"of times with a buffer view. If the callback returns a false value\n" -"(such as None), the given buffer is out-of-band; otherwise the\n" -"buffer is serialized in-band, i.e. inside the pickle stream.\n" -"\n" -"It is an error if *buffer_callback* is not None and *protocol*\n" -"is None or smaller than 5."); +"2, so that the pickle data stream is readable with Python 2.\n" +"\n" +"If *buffer_callback* is None (the default), buffer views are\n" +"serialized into *file* as part of the pickle stream.\n" +"\n" +"If *buffer_callback* is not None, then it can be called any number\n" +"of times with a buffer view. If the callback returns a false value\n" +"(such as None), the given buffer is out-of-band; otherwise the\n" +"buffer is serialized in-band, i.e. inside the pickle stream.\n" +"\n" +"It is an error if *buffer_callback* is not None and *protocol*\n" +"is None or smaller than 5."); static int _pickle_Pickler___init___impl(PicklerObject *self, PyObject *file, - PyObject *protocol, int fix_imports, - PyObject *buffer_callback); + PyObject *protocol, int fix_imports, + PyObject *buffer_callback); static int _pickle_Pickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"file", "protocol", "fix_imports", "buffer_callback", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Pickler", 0}; - PyObject *argsbuf[4]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + static const char * const _keywords[] = {"file", "protocol", "fix_imports", "buffer_callback", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "Pickler", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *file; - PyObject *protocol = Py_None; + PyObject *protocol = Py_None; int fix_imports = 1; - PyObject *buffer_callback = Py_None; + PyObject *buffer_callback = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); + if (!fastargs) { goto exit; } - file = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[1]) { - protocol = fastargs[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[2]) { - fix_imports = PyObject_IsTrue(fastargs[2]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - buffer_callback = fastargs[3]; -skip_optional_pos: - return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports, buffer_callback); + file = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + protocol = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + fix_imports = PyObject_IsTrue(fastargs[2]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + buffer_callback = fastargs[3]; +skip_optional_pos: + return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports, buffer_callback); exit: return return_value; @@ -238,7 +238,7 @@ PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__, "needed. Both arguments passed are str objects."); #define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF \ - {"find_class", (PyCFunction)(void(*)(void))_pickle_Unpickler_find_class, METH_FASTCALL, _pickle_Unpickler_find_class__doc__}, + {"find_class", (PyCFunction)(void(*)(void))_pickle_Unpickler_find_class, METH_FASTCALL, _pickle_Unpickler_find_class__doc__}, static PyObject * _pickle_Unpickler_find_class_impl(UnpicklerObject *self, @@ -252,11 +252,11 @@ _pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *const *args, Py_ss PyObject *module_name; PyObject *global_name; - if (!_PyArg_CheckPositional("find_class", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("find_class", nargs, 2, 2)) { goto exit; } - module_name = args[0]; - global_name = args[1]; + module_name = args[0]; + global_name = args[1]; return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name); exit: @@ -292,8 +292,8 @@ exit: } PyDoc_STRVAR(_pickle_Unpickler___init____doc__, -"Unpickler(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\',\n" -" buffers=())\n" +"Unpickler(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\',\n" +" buffers=())\n" "--\n" "\n" "This takes a binary file for reading a pickle data stream.\n" @@ -320,80 +320,80 @@ PyDoc_STRVAR(_pickle_Unpickler___init____doc__, static int _pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file, int fix_imports, const char *encoding, - const char *errors, PyObject *buffers); + const char *errors, PyObject *buffers); static int _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Unpickler", 0}; - PyObject *argsbuf[5]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "Unpickler", 0}; + PyObject *argsbuf[5]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *file; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - PyObject *buffers = NULL; + PyObject *buffers = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - file = fastargs[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (fastargs[1]) { - fix_imports = PyObject_IsTrue(fastargs[1]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[2]) { - if (!PyUnicode_Check(fastargs[2])) { - _PyArg_BadArgument("Unpickler", "argument 'encoding'", "str", fastargs[2]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[3]) { - if (!PyUnicode_Check(fastargs[3])) { - _PyArg_BadArgument("Unpickler", "argument 'errors'", "str", fastargs[3]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(fastargs[3], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - buffers = fastargs[4]; -skip_optional_kwonly: - return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors, buffers); + file = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + fix_imports = PyObject_IsTrue(fastargs[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + if (!PyUnicode_Check(fastargs[2])) { + _PyArg_BadArgument("Unpickler", "argument 'encoding'", "str", fastargs[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + if (!PyUnicode_Check(fastargs[3])) { + _PyArg_BadArgument("Unpickler", "argument 'errors'", "str", fastargs[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(fastargs[3], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + buffers = fastargs[4]; +skip_optional_kwonly: + return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors, buffers); exit: return return_value; @@ -454,8 +454,8 @@ _pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject *self, PyObject * } PyDoc_STRVAR(_pickle_dump__doc__, -"dump($module, /, obj, file, protocol=None, *, fix_imports=True,\n" -" buffer_callback=None)\n" +"dump($module, /, obj, file, protocol=None, *, fix_imports=True,\n" +" buffer_callback=None)\n" "--\n" "\n" "Write a pickled representation of obj to the open file object file.\n" @@ -464,9 +464,9 @@ PyDoc_STRVAR(_pickle_dump__doc__, "be more efficient.\n" "\n" "The optional *protocol* argument tells the pickler to use the given\n" -"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" -"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" -"with previous versions.\n" +"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" +"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" +"with previous versions.\n" "\n" "Specifying a negative protocol version selects the highest protocol\n" "version supported. The higher the protocol used, the more recent the\n" @@ -479,81 +479,81 @@ PyDoc_STRVAR(_pickle_dump__doc__, "\n" "If *fix_imports* is True and protocol is less than 3, pickle will try\n" "to map the new Python 3 names to the old module names used in Python\n" -"2, so that the pickle data stream is readable with Python 2.\n" -"\n" -"If *buffer_callback* is None (the default), buffer views are serialized\n" -"into *file* as part of the pickle stream. It is an error if\n" -"*buffer_callback* is not None and *protocol* is None or smaller than 5."); +"2, so that the pickle data stream is readable with Python 2.\n" +"\n" +"If *buffer_callback* is None (the default), buffer views are serialized\n" +"into *file* as part of the pickle stream. It is an error if\n" +"*buffer_callback* is not None and *protocol* is None or smaller than 5."); #define _PICKLE_DUMP_METHODDEF \ - {"dump", (PyCFunction)(void(*)(void))_pickle_dump, METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__}, + {"dump", (PyCFunction)(void(*)(void))_pickle_dump, METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__}, static PyObject * _pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file, - PyObject *protocol, int fix_imports, - PyObject *buffer_callback); + PyObject *protocol, int fix_imports, + PyObject *buffer_callback); static PyObject * _pickle_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"obj", "file", "protocol", "fix_imports", "buffer_callback", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "dump", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static const char * const _keywords[] = {"obj", "file", "protocol", "fix_imports", "buffer_callback", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "dump", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *obj; PyObject *file; - PyObject *protocol = Py_None; + PyObject *protocol = Py_None; int fix_imports = 1; - PyObject *buffer_callback = Py_None; + PyObject *buffer_callback = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } - obj = args[0]; - file = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - protocol = args[2]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[3]) { - fix_imports = PyObject_IsTrue(args[3]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - buffer_callback = args[4]; -skip_optional_kwonly: - return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports, buffer_callback); + obj = args[0]; + file = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + protocol = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + fix_imports = PyObject_IsTrue(args[3]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + buffer_callback = args[4]; +skip_optional_kwonly: + return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports, buffer_callback); exit: return return_value; } PyDoc_STRVAR(_pickle_dumps__doc__, -"dumps($module, /, obj, protocol=None, *, fix_imports=True,\n" -" buffer_callback=None)\n" +"dumps($module, /, obj, protocol=None, *, fix_imports=True,\n" +" buffer_callback=None)\n" "--\n" "\n" "Return the pickled representation of the object as a bytes object.\n" "\n" "The optional *protocol* argument tells the pickler to use the given\n" -"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" -"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" -"with previous versions.\n" +"protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default\n" +"protocol is 4. It was introduced in Python 3.4, and is incompatible\n" +"with previous versions.\n" "\n" "Specifying a negative protocol version selects the highest protocol\n" "version supported. The higher the protocol used, the more recent the\n" @@ -561,62 +561,62 @@ PyDoc_STRVAR(_pickle_dumps__doc__, "\n" "If *fix_imports* is True and *protocol* is less than 3, pickle will\n" "try to map the new Python 3 names to the old module names used in\n" -"Python 2, so that the pickle data stream is readable with Python 2.\n" -"\n" -"If *buffer_callback* is None (the default), buffer views are serialized\n" -"into *file* as part of the pickle stream. It is an error if\n" -"*buffer_callback* is not None and *protocol* is None or smaller than 5."); +"Python 2, so that the pickle data stream is readable with Python 2.\n" +"\n" +"If *buffer_callback* is None (the default), buffer views are serialized\n" +"into *file* as part of the pickle stream. It is an error if\n" +"*buffer_callback* is not None and *protocol* is None or smaller than 5."); #define _PICKLE_DUMPS_METHODDEF \ - {"dumps", (PyCFunction)(void(*)(void))_pickle_dumps, METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__}, + {"dumps", (PyCFunction)(void(*)(void))_pickle_dumps, METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__}, static PyObject * _pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol, - int fix_imports, PyObject *buffer_callback); + int fix_imports, PyObject *buffer_callback); static PyObject * _pickle_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"obj", "protocol", "fix_imports", "buffer_callback", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "dumps", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"obj", "protocol", "fix_imports", "buffer_callback", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "dumps", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; - PyObject *protocol = Py_None; + PyObject *protocol = Py_None; int fix_imports = 1; - PyObject *buffer_callback = Py_None; + PyObject *buffer_callback = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - obj = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - protocol = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - fix_imports = PyObject_IsTrue(args[2]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - buffer_callback = args[3]; -skip_optional_kwonly: - return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports, buffer_callback); + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + protocol = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + fix_imports = PyObject_IsTrue(args[2]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + buffer_callback = args[3]; +skip_optional_kwonly: + return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports, buffer_callback); exit: return return_value; @@ -624,7 +624,7 @@ exit: PyDoc_STRVAR(_pickle_load__doc__, "load($module, /, file, *, fix_imports=True, encoding=\'ASCII\',\n" -" errors=\'strict\', buffers=())\n" +" errors=\'strict\', buffers=())\n" "--\n" "\n" "Read and return an object from the pickle data stored in a file.\n" @@ -652,91 +652,91 @@ PyDoc_STRVAR(_pickle_load__doc__, "string instances as bytes objects."); #define _PICKLE_LOAD_METHODDEF \ - {"load", (PyCFunction)(void(*)(void))_pickle_load, METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__}, + {"load", (PyCFunction)(void(*)(void))_pickle_load, METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__}, static PyObject * _pickle_load_impl(PyObject *module, PyObject *file, int fix_imports, - const char *encoding, const char *errors, - PyObject *buffers); + const char *encoding, const char *errors, + PyObject *buffers); static PyObject * _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "load", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "load", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *file; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - PyObject *buffers = NULL; + PyObject *buffers = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - file = args[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[1]) { - fix_imports = PyObject_IsTrue(args[1]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[2]) { - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("load", "argument 'encoding'", "str", args[2]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (!PyUnicode_Check(args[3])) { - _PyArg_BadArgument("load", "argument 'errors'", "str", args[3]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - buffers = args[4]; -skip_optional_kwonly: - return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors, buffers); + file = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + fix_imports = PyObject_IsTrue(args[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("load", "argument 'encoding'", "str", args[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!PyUnicode_Check(args[3])) { + _PyArg_BadArgument("load", "argument 'errors'", "str", args[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + buffers = args[4]; +skip_optional_kwonly: + return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors, buffers); exit: return return_value; } PyDoc_STRVAR(_pickle_loads__doc__, -"loads($module, data, /, *, fix_imports=True, encoding=\'ASCII\',\n" -" errors=\'strict\', buffers=())\n" +"loads($module, data, /, *, fix_imports=True, encoding=\'ASCII\',\n" +" errors=\'strict\', buffers=())\n" "--\n" "\n" "Read and return an object from the given pickle data.\n" @@ -755,85 +755,85 @@ PyDoc_STRVAR(_pickle_loads__doc__, "string instances as bytes objects."); #define _PICKLE_LOADS_METHODDEF \ - {"loads", (PyCFunction)(void(*)(void))_pickle_loads, METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__}, + {"loads", (PyCFunction)(void(*)(void))_pickle_loads, METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__}, static PyObject * _pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports, - const char *encoding, const char *errors, - PyObject *buffers); + const char *encoding, const char *errors, + PyObject *buffers); static PyObject * _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "fix_imports", "encoding", "errors", "buffers", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "loads", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"", "fix_imports", "encoding", "errors", "buffers", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "loads", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *data; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - PyObject *buffers = NULL; + PyObject *buffers = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - data = args[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[1]) { - fix_imports = PyObject_IsTrue(args[1]); - if (fix_imports < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[2]) { - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("loads", "argument 'encoding'", "str", args[2]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (!PyUnicode_Check(args[3])) { - _PyArg_BadArgument("loads", "argument 'errors'", "str", args[3]); - goto exit; - } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - buffers = args[4]; -skip_optional_kwonly: - return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors, buffers); + data = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + fix_imports = PyObject_IsTrue(args[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("loads", "argument 'encoding'", "str", args[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!PyUnicode_Check(args[3])) { + _PyArg_BadArgument("loads", "argument 'errors'", "str", args[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + buffers = args[4]; +skip_optional_kwonly: + return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors, buffers); exit: return return_value; } -/*[clinic end generated code: output=324aad69644beda2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=324aad69644beda2 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h b/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h index c25eacf08b..d2179ccdaa 100644 --- a/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h @@ -40,7 +40,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_put__doc__, "never blocks. They are provided for compatibility with the Queue class."); #define _QUEUE_SIMPLEQUEUE_PUT_METHODDEF \ - {"put", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__}, + {"put", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__}, static PyObject * _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item, @@ -51,32 +51,32 @@ _queue_SimpleQueue_put(simplequeueobject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"item", "block", "timeout", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "put", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "put", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *item; int block = 1; PyObject *timeout = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - item = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - block = PyObject_IsTrue(args[1]); - if (block < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - timeout = args[2]; -skip_optional_pos: + item = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + block = PyObject_IsTrue(args[1]); + if (block < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + timeout = args[2]; +skip_optional_pos: return_value = _queue_SimpleQueue_put_impl(self, item, block, timeout); exit: @@ -93,7 +93,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_put_nowait__doc__, "for compatibility with the Queue class."); #define _QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF \ - {"put_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put_nowait, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__}, + {"put_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put_nowait, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__}, static PyObject * _queue_SimpleQueue_put_nowait_impl(simplequeueobject *self, PyObject *item); @@ -103,15 +103,15 @@ _queue_SimpleQueue_put_nowait(simplequeueobject *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"item", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "put_nowait", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "put_nowait", 0}; + PyObject *argsbuf[1]; PyObject *item; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - item = args[0]; + item = args[0]; return_value = _queue_SimpleQueue_put_nowait_impl(self, item); exit: @@ -133,7 +133,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_get__doc__, "in that case)."); #define _QUEUE_SIMPLEQUEUE_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__}, + {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__}, static PyObject * _queue_SimpleQueue_get_impl(simplequeueobject *self, int block, @@ -144,30 +144,30 @@ _queue_SimpleQueue_get(simplequeueobject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"block", "timeout", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int block = 1; PyObject *timeout = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); - if (!args) { + 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]) { - block = PyObject_IsTrue(args[0]); - if (block < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - timeout = args[1]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + block = PyObject_IsTrue(args[0]); + if (block < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + timeout = args[1]; +skip_optional_pos: return_value = _queue_SimpleQueue_get_impl(self, block, timeout); exit: @@ -250,4 +250,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=b4717e2974cbc909 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b4717e2974cbc909 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_randommodule.c.h b/contrib/tools/python3/src/Modules/clinic/_randommodule.c.h index a467811d93..c598cc0053 100644 --- a/contrib/tools/python3/src/Modules/clinic/_randommodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_randommodule.c.h @@ -1,117 +1,117 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_random_Random_random__doc__, -"random($self, /)\n" -"--\n" -"\n" -"random() -> x in the interval [0, 1)."); - -#define _RANDOM_RANDOM_RANDOM_METHODDEF \ - {"random", (PyCFunction)_random_Random_random, METH_NOARGS, _random_Random_random__doc__}, - -static PyObject * -_random_Random_random_impl(RandomObject *self); - -static PyObject * -_random_Random_random(RandomObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _random_Random_random_impl(self); -} - -PyDoc_STRVAR(_random_Random_seed__doc__, -"seed($self, n=None, /)\n" -"--\n" -"\n" -"seed([n]) -> None.\n" -"\n" -"Defaults to use urandom and falls back to a combination\n" -"of the current time and the process identifier."); - -#define _RANDOM_RANDOM_SEED_METHODDEF \ - {"seed", (PyCFunction)(void(*)(void))_random_Random_seed, METH_FASTCALL, _random_Random_seed__doc__}, - -static PyObject * -_random_Random_seed_impl(RandomObject *self, PyObject *n); - -static PyObject * -_random_Random_seed(RandomObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *n = Py_None; - - if (!_PyArg_CheckPositional("seed", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - n = args[0]; -skip_optional: - return_value = _random_Random_seed_impl(self, n); - -exit: - return return_value; -} - -PyDoc_STRVAR(_random_Random_getstate__doc__, -"getstate($self, /)\n" -"--\n" -"\n" -"getstate() -> tuple containing the current state."); - -#define _RANDOM_RANDOM_GETSTATE_METHODDEF \ - {"getstate", (PyCFunction)_random_Random_getstate, METH_NOARGS, _random_Random_getstate__doc__}, - -static PyObject * -_random_Random_getstate_impl(RandomObject *self); - -static PyObject * -_random_Random_getstate(RandomObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _random_Random_getstate_impl(self); -} - -PyDoc_STRVAR(_random_Random_setstate__doc__, -"setstate($self, state, /)\n" -"--\n" -"\n" -"setstate(state) -> None. Restores generator state."); - -#define _RANDOM_RANDOM_SETSTATE_METHODDEF \ - {"setstate", (PyCFunction)_random_Random_setstate, METH_O, _random_Random_setstate__doc__}, - -PyDoc_STRVAR(_random_Random_getrandbits__doc__, -"getrandbits($self, k, /)\n" -"--\n" -"\n" -"getrandbits(k) -> x. Generates an int with k random bits."); - -#define _RANDOM_RANDOM_GETRANDBITS_METHODDEF \ - {"getrandbits", (PyCFunction)_random_Random_getrandbits, METH_O, _random_Random_getrandbits__doc__}, - -static PyObject * -_random_Random_getrandbits_impl(RandomObject *self, int k); - -static PyObject * -_random_Random_getrandbits(RandomObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int k; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - k = _PyLong_AsInt(arg); - if (k == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _random_Random_getrandbits_impl(self, k); - -exit: - return return_value; -} -/*[clinic end generated code: output=a7feb0c9c8d1b627 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_random_Random_random__doc__, +"random($self, /)\n" +"--\n" +"\n" +"random() -> x in the interval [0, 1)."); + +#define _RANDOM_RANDOM_RANDOM_METHODDEF \ + {"random", (PyCFunction)_random_Random_random, METH_NOARGS, _random_Random_random__doc__}, + +static PyObject * +_random_Random_random_impl(RandomObject *self); + +static PyObject * +_random_Random_random(RandomObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _random_Random_random_impl(self); +} + +PyDoc_STRVAR(_random_Random_seed__doc__, +"seed($self, n=None, /)\n" +"--\n" +"\n" +"seed([n]) -> None.\n" +"\n" +"Defaults to use urandom and falls back to a combination\n" +"of the current time and the process identifier."); + +#define _RANDOM_RANDOM_SEED_METHODDEF \ + {"seed", (PyCFunction)(void(*)(void))_random_Random_seed, METH_FASTCALL, _random_Random_seed__doc__}, + +static PyObject * +_random_Random_seed_impl(RandomObject *self, PyObject *n); + +static PyObject * +_random_Random_seed(RandomObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *n = Py_None; + + if (!_PyArg_CheckPositional("seed", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + n = args[0]; +skip_optional: + return_value = _random_Random_seed_impl(self, n); + +exit: + return return_value; +} + +PyDoc_STRVAR(_random_Random_getstate__doc__, +"getstate($self, /)\n" +"--\n" +"\n" +"getstate() -> tuple containing the current state."); + +#define _RANDOM_RANDOM_GETSTATE_METHODDEF \ + {"getstate", (PyCFunction)_random_Random_getstate, METH_NOARGS, _random_Random_getstate__doc__}, + +static PyObject * +_random_Random_getstate_impl(RandomObject *self); + +static PyObject * +_random_Random_getstate(RandomObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _random_Random_getstate_impl(self); +} + +PyDoc_STRVAR(_random_Random_setstate__doc__, +"setstate($self, state, /)\n" +"--\n" +"\n" +"setstate(state) -> None. Restores generator state."); + +#define _RANDOM_RANDOM_SETSTATE_METHODDEF \ + {"setstate", (PyCFunction)_random_Random_setstate, METH_O, _random_Random_setstate__doc__}, + +PyDoc_STRVAR(_random_Random_getrandbits__doc__, +"getrandbits($self, k, /)\n" +"--\n" +"\n" +"getrandbits(k) -> x. Generates an int with k random bits."); + +#define _RANDOM_RANDOM_GETRANDBITS_METHODDEF \ + {"getrandbits", (PyCFunction)_random_Random_getrandbits, METH_O, _random_Random_getrandbits__doc__}, + +static PyObject * +_random_Random_getrandbits_impl(RandomObject *self, int k); + +static PyObject * +_random_Random_getrandbits(RandomObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int k; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + k = _PyLong_AsInt(arg); + if (k == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _random_Random_getrandbits_impl(self, k); + +exit: + return return_value; +} +/*[clinic end generated code: output=a7feb0c9c8d1b627 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_sre.c.h b/contrib/tools/python3/src/Modules/clinic/_sre.c.h index d398a8504b..d8bd75e2f4 100644 --- a/contrib/tools/python3/src/Modules/clinic/_sre.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_sre.c.h @@ -47,15 +47,15 @@ _sre_ascii_iscased(PyObject *module, PyObject *arg) int character; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - character = _PyLong_AsInt(arg); - if (character == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + character = _PyLong_AsInt(arg); + if (character == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = _sre_ascii_iscased_impl(module, character); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -84,15 +84,15 @@ _sre_unicode_iscased(PyObject *module, PyObject *arg) int character; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - character = _PyLong_AsInt(arg); - if (character == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + character = _PyLong_AsInt(arg); + if (character == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = _sre_unicode_iscased_impl(module, character); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -121,15 +121,15 @@ _sre_ascii_tolower(PyObject *module, PyObject *arg) int character; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - character = _PyLong_AsInt(arg); - if (character == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + character = _PyLong_AsInt(arg); + if (character == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = _sre_ascii_tolower_impl(module, character); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -158,15 +158,15 @@ _sre_unicode_tolower(PyObject *module, PyObject *arg) int character; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - character = _PyLong_AsInt(arg); - if (character == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + character = _PyLong_AsInt(arg); + if (character == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = _sre_unicode_tolower_impl(module, character); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -184,7 +184,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__, "Matches zero or more characters at the beginning of the string."); #define _SRE_SRE_PATTERN_MATCH_METHODDEF \ - {"match", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_match, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, + {"match", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_match, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, static PyObject * _sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string, @@ -195,61 +195,61 @@ _sre_SRE_Pattern_match(PatternObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "match", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "match", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos); exit: @@ -263,7 +263,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__, "Matches against all of the string."); #define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF \ - {"fullmatch", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_fullmatch, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__}, + {"fullmatch", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_fullmatch, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__}, static PyObject * _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string, @@ -274,61 +274,61 @@ _sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos); exit: @@ -344,7 +344,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__, "Return None if no position in the string matches."); #define _SRE_SRE_PATTERN_SEARCH_METHODDEF \ - {"search", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_search, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__}, + {"search", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_search, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__}, static PyObject * _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string, @@ -355,61 +355,61 @@ _sre_SRE_Pattern_search(PatternObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "search", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "search", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos); exit: @@ -423,7 +423,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__, "Return a list of all non-overlapping matches of pattern in string."); #define _SRE_SRE_PATTERN_FINDALL_METHODDEF \ - {"findall", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_findall, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__}, + {"findall", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_findall, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__}, static PyObject * _sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string, @@ -434,61 +434,61 @@ _sre_SRE_Pattern_findall(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos); exit: @@ -504,7 +504,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_finditer__doc__, "For each match, the iterator returns a match object."); #define _SRE_SRE_PATTERN_FINDITER_METHODDEF \ - {"finditer", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_finditer, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__}, + {"finditer", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_finditer, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__}, static PyObject * _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyObject *string, @@ -515,61 +515,61 @@ _sre_SRE_Pattern_finditer(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_finditer_impl(self, string, pos, endpos); exit: @@ -582,7 +582,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_scanner__doc__, "\n"); #define _SRE_SRE_PATTERN_SCANNER_METHODDEF \ - {"scanner", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_scanner, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__}, + {"scanner", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_scanner, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__}, static PyObject * _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyObject *string, @@ -593,61 +593,61 @@ _sre_SRE_Pattern_scanner(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - pos = ival; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - endpos = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_scanner_impl(self, string, pos, endpos); exit: @@ -661,7 +661,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__, "Split string by the occurrences of pattern."); #define _SRE_SRE_PATTERN_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_split, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__}, + {"split", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_split, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__}, static PyObject * _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, @@ -672,38 +672,38 @@ _sre_SRE_Pattern_split(PatternObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t maxsplit = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - string = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - maxsplit = ival; - } -skip_optional_pos: + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit); exit: @@ -717,7 +717,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__, "Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl."); #define _SRE_SRE_PATTERN_SUB_METHODDEF \ - {"sub", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_sub, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__}, + {"sub", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_sub, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__}, static PyObject * _sre_SRE_Pattern_sub_impl(PatternObject *self, PyObject *repl, @@ -728,40 +728,40 @@ _sre_SRE_Pattern_sub(PatternObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } - repl = args[0]; - string = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - count = ival; - } -skip_optional_pos: + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_sub_impl(self, repl, string, count); exit: @@ -775,7 +775,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc__, "Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl."); #define _SRE_SRE_PATTERN_SUBN_METHODDEF \ - {"subn", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_subn, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__}, + {"subn", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_subn, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__}, static PyObject * _sre_SRE_Pattern_subn_impl(PatternObject *self, PyObject *repl, @@ -786,40 +786,40 @@ _sre_SRE_Pattern_subn(PatternObject *self, PyObject *const *args, Py_ssize_t nar { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - repl = args[0]; - string = args[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - count = ival; - } -skip_optional_pos: + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_subn_impl(self, repl, string, count); exit: @@ -858,7 +858,7 @@ PyDoc_STRVAR(_sre_compile__doc__, "\n"); #define _SRE_COMPILE_METHODDEF \ - {"compile", (PyCFunction)(void(*)(void))_sre_compile, METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__}, + {"compile", (PyCFunction)(void(*)(void))_sre_compile, METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__}, static PyObject * _sre_compile_impl(PyObject *module, PyObject *pattern, int flags, @@ -870,8 +870,8 @@ _sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0}; - PyObject *argsbuf[6]; + static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0}; + PyObject *argsbuf[6]; PyObject *pattern; int flags; PyObject *code; @@ -879,52 +879,52 @@ _sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject PyObject *groupindex; PyObject *indexgroup; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 6, 6, 0, argsbuf); - if (!args) { - goto exit; - } - pattern = args[0]; - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - if (!PyList_Check(args[2])) { - _PyArg_BadArgument("compile", "argument 'code'", "list", args[2]); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 6, 6, 0, argsbuf); + if (!args) { goto exit; } - code = args[2]; - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[3]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - groups = ival; - } - if (!PyDict_Check(args[4])) { - _PyArg_BadArgument("compile", "argument 'groupindex'", "dict", args[4]); - goto exit; - } - groupindex = args[4]; - if (!PyTuple_Check(args[5])) { - _PyArg_BadArgument("compile", "argument 'indexgroup'", "tuple", args[5]); - goto exit; - } - indexgroup = args[5]; + pattern = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyList_Check(args[2])) { + _PyArg_BadArgument("compile", "argument 'code'", "list", args[2]); + goto exit; + } + code = args[2]; + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[3]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + groups = ival; + } + if (!PyDict_Check(args[4])) { + _PyArg_BadArgument("compile", "argument 'groupindex'", "dict", args[4]); + goto exit; + } + groupindex = args[4]; + if (!PyTuple_Check(args[5])) { + _PyArg_BadArgument("compile", "argument 'indexgroup'", "tuple", args[5]); + goto exit; + } + indexgroup = args[5]; return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup); exit: @@ -938,7 +938,7 @@ PyDoc_STRVAR(_sre_SRE_Match_expand__doc__, "Return the string obtained by doing backslash substitution on the string template, as done by the sub() method."); #define _SRE_SRE_MATCH_EXPAND_METHODDEF \ - {"expand", (PyCFunction)(void(*)(void))_sre_SRE_Match_expand, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__}, + {"expand", (PyCFunction)(void(*)(void))_sre_SRE_Match_expand, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__}, static PyObject * _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template); @@ -948,15 +948,15 @@ _sre_SRE_Match_expand(MatchObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"template", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "expand", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "expand", 0}; + PyObject *argsbuf[1]; PyObject *template; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - template = args[0]; + template = args[0]; return_value = _sre_SRE_Match_expand_impl(self, template); exit: @@ -973,7 +973,7 @@ PyDoc_STRVAR(_sre_SRE_Match_groups__doc__, " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPS_METHODDEF \ - {"groups", (PyCFunction)(void(*)(void))_sre_SRE_Match_groups, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, + {"groups", (PyCFunction)(void(*)(void))_sre_SRE_Match_groups, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, static PyObject * _sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value); @@ -983,20 +983,20 @@ _sre_SRE_Match_groups(MatchObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"default", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "groups", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "groups", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *default_value = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - default_value = args[0]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[0]; +skip_optional_pos: return_value = _sre_SRE_Match_groups_impl(self, default_value); exit: @@ -1013,7 +1013,7 @@ PyDoc_STRVAR(_sre_SRE_Match_groupdict__doc__, " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPDICT_METHODDEF \ - {"groupdict", (PyCFunction)(void(*)(void))_sre_SRE_Match_groupdict, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, + {"groupdict", (PyCFunction)(void(*)(void))_sre_SRE_Match_groupdict, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, static PyObject * _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value); @@ -1023,20 +1023,20 @@ _sre_SRE_Match_groupdict(MatchObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"default", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "groupdict", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "groupdict", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *default_value = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - default_value = args[0]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[0]; +skip_optional_pos: return_value = _sre_SRE_Match_groupdict_impl(self, default_value); exit: @@ -1050,7 +1050,7 @@ PyDoc_STRVAR(_sre_SRE_Match_start__doc__, "Return index of the start of the substring matched by group."); #define _SRE_SRE_MATCH_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_sre_SRE_Match_start, METH_FASTCALL, _sre_SRE_Match_start__doc__}, + {"start", (PyCFunction)(void(*)(void))_sre_SRE_Match_start, METH_FASTCALL, _sre_SRE_Match_start__doc__}, static Py_ssize_t _sre_SRE_Match_start_impl(MatchObject *self, PyObject *group); @@ -1062,14 +1062,14 @@ _sre_SRE_Match_start(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *group = NULL; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("start", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("start", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - group = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + group = args[0]; +skip_optional: _return_value = _sre_SRE_Match_start_impl(self, group); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -1087,7 +1087,7 @@ PyDoc_STRVAR(_sre_SRE_Match_end__doc__, "Return index of the end of the substring matched by group."); #define _SRE_SRE_MATCH_END_METHODDEF \ - {"end", (PyCFunction)(void(*)(void))_sre_SRE_Match_end, METH_FASTCALL, _sre_SRE_Match_end__doc__}, + {"end", (PyCFunction)(void(*)(void))_sre_SRE_Match_end, METH_FASTCALL, _sre_SRE_Match_end__doc__}, static Py_ssize_t _sre_SRE_Match_end_impl(MatchObject *self, PyObject *group); @@ -1099,14 +1099,14 @@ _sre_SRE_Match_end(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *group = NULL; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("end", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("end", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - group = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + group = args[0]; +skip_optional: _return_value = _sre_SRE_Match_end_impl(self, group); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -1124,7 +1124,7 @@ PyDoc_STRVAR(_sre_SRE_Match_span__doc__, "For match object m, return the 2-tuple (m.start(group), m.end(group))."); #define _SRE_SRE_MATCH_SPAN_METHODDEF \ - {"span", (PyCFunction)(void(*)(void))_sre_SRE_Match_span, METH_FASTCALL, _sre_SRE_Match_span__doc__}, + {"span", (PyCFunction)(void(*)(void))_sre_SRE_Match_span, METH_FASTCALL, _sre_SRE_Match_span__doc__}, static PyObject * _sre_SRE_Match_span_impl(MatchObject *self, PyObject *group); @@ -1135,14 +1135,14 @@ _sre_SRE_Match_span(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *group = NULL; - if (!_PyArg_CheckPositional("span", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("span", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - group = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + group = args[0]; +skip_optional: return_value = _sre_SRE_Match_span_impl(self, group); exit: @@ -1207,4 +1207,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored)) { return _sre_SRE_Scanner_search_impl(self); } -/*[clinic end generated code: output=1adeddce58ae284c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1adeddce58ae284c input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_ssl.c.h b/contrib/tools/python3/src/Modules/clinic/_ssl.c.h index ce8669ae21..15fe9201fe 100644 --- a/contrib/tools/python3/src/Modules/clinic/_ssl.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_ssl.c.h @@ -36,7 +36,7 @@ _ssl__test_decode_cert(PyObject *module, PyObject *arg) PyObject *return_value = NULL; PyObject *path; - if (!PyUnicode_FSConverter(arg, &path)) { + if (!PyUnicode_FSConverter(arg, &path)) { goto exit; } return_value = _ssl__test_decode_cert_impl(module, path); @@ -60,7 +60,7 @@ PyDoc_STRVAR(_ssl__SSLSocket_getpeercert__doc__, "return the certificate even if it wasn\'t validated."); #define _SSL__SSLSOCKET_GETPEERCERT_METHODDEF \ - {"getpeercert", (PyCFunction)(void(*)(void))_ssl__SSLSocket_getpeercert, METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__}, + {"getpeercert", (PyCFunction)(void(*)(void))_ssl__SSLSocket_getpeercert, METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__}, static PyObject * _ssl__SSLSocket_getpeercert_impl(PySSLSocket *self, int binary_mode); @@ -71,17 +71,17 @@ _ssl__SSLSocket_getpeercert(PySSLSocket *self, PyObject *const *args, Py_ssize_t PyObject *return_value = NULL; int binary_mode = 0; - if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - binary_mode = PyObject_IsTrue(args[0]); - if (binary_mode < 0) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + binary_mode = PyObject_IsTrue(args[0]); + if (binary_mode < 0) { + goto exit; + } +skip_optional: return_value = _ssl__SSLSocket_getpeercert_impl(self, binary_mode); exit: @@ -218,13 +218,13 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer b = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&b, 'C')) { - _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&b, 'C')) { + _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _ssl__SSLSocket_write_impl(self, &b); exit: @@ -329,7 +329,7 @@ PyDoc_STRVAR(_ssl__SSLSocket_get_channel_binding__doc__, "Only \'tls-unique\' channel binding data from RFC 5929 is supported."); #define _SSL__SSLSOCKET_GET_CHANNEL_BINDING_METHODDEF \ - {"get_channel_binding", (PyCFunction)(void(*)(void))_ssl__SSLSocket_get_channel_binding, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__}, + {"get_channel_binding", (PyCFunction)(void(*)(void))_ssl__SSLSocket_get_channel_binding, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__}, static PyObject * _ssl__SSLSocket_get_channel_binding_impl(PySSLSocket *self, @@ -340,32 +340,32 @@ _ssl__SSLSocket_get_channel_binding(PySSLSocket *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"cb_type", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get_channel_binding", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "get_channel_binding", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *cb_type = "tls-unique"; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("get_channel_binding", "argument 'cb_type'", "str", args[0]); - goto exit; - } - Py_ssize_t cb_type_length; - cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length); - if (cb_type == NULL) { - goto exit; - } - if (strlen(cb_type) != (size_t)cb_type_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("get_channel_binding", "argument 'cb_type'", "str", args[0]); + goto exit; + } + Py_ssize_t cb_type_length; + cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length); + if (cb_type == NULL) { + goto exit; + } + if (strlen(cb_type) != (size_t)cb_type_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = _ssl__SSLSocket_get_channel_binding_impl(self, cb_type); exit: @@ -403,18 +403,18 @@ _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("_SSLContext", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) { - goto exit; - } - if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - proto_version = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); - if (proto_version == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) { goto exit; } + if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + proto_version = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); + if (proto_version == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _ssl__SSLContext_impl(type, proto_version); exit: @@ -438,19 +438,19 @@ _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg) PyObject *return_value = NULL; const char *cipherlist; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("set_ciphers", "argument", "str", arg); - goto exit; - } - Py_ssize_t cipherlist_length; - cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length); - if (cipherlist == NULL) { - goto exit; - } - if (strlen(cipherlist) != (size_t)cipherlist_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("set_ciphers", "argument", "str", arg); goto exit; } + Py_ssize_t cipherlist_length; + cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length); + if (cipherlist == NULL) { + goto exit; + } + if (strlen(cipherlist) != (size_t)cipherlist_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist); exit: @@ -496,13 +496,13 @@ _ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer protos = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&protos, 'C')) { - _PyArg_BadArgument("_set_npn_protocols", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&protos, 'C')) { + _PyArg_BadArgument("_set_npn_protocols", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos); exit: @@ -532,13 +532,13 @@ _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer protos = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&protos, 'C')) { - _PyArg_BadArgument("_set_alpn_protocols", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&protos, 'C')) { + _PyArg_BadArgument("_set_alpn_protocols", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos); exit: @@ -556,7 +556,7 @@ PyDoc_STRVAR(_ssl__SSLContext_load_cert_chain__doc__, "\n"); #define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \ - {"load_cert_chain", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_cert_chain, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__}, + {"load_cert_chain", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_cert_chain, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__}, static PyObject * _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile, @@ -567,29 +567,29 @@ _ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *const *args, Py_s { PyObject *return_value = NULL; static const char * const _keywords[] = {"certfile", "keyfile", "password", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "load_cert_chain", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "load_cert_chain", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *certfile; - PyObject *keyfile = Py_None; - PyObject *password = Py_None; + PyObject *keyfile = Py_None; + PyObject *password = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } - certfile = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - keyfile = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - password = args[2]; -skip_optional_pos: + certfile = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + keyfile = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + password = args[2]; +skip_optional_pos: return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password); exit: @@ -602,7 +602,7 @@ PyDoc_STRVAR(_ssl__SSLContext_load_verify_locations__doc__, "\n"); #define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF \ - {"load_verify_locations", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_verify_locations, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__}, + {"load_verify_locations", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_verify_locations, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__}, static PyObject * _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self, @@ -615,34 +615,34 @@ _ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *const *args { PyObject *return_value = NULL; static const char * const _keywords[] = {"cafile", "capath", "cadata", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "load_verify_locations", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *cafile = Py_None; - PyObject *capath = Py_None; - PyObject *cadata = Py_None; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); - if (!args) { + static _PyArg_Parser _parser = {NULL, _keywords, "load_verify_locations", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *cafile = Py_None; + PyObject *capath = Py_None; + PyObject *cadata = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - cafile = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[1]) { - capath = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - cadata = args[2]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + cafile = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + capath = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + cadata = args[2]; +skip_optional_pos: return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata); exit: @@ -664,7 +664,7 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_socket__doc__, "\n"); #define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF \ - {"_wrap_socket", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_socket, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__}, + {"_wrap_socket", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_socket, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__}, static PyObject * _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock, @@ -676,54 +676,54 @@ _ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"sock", "server_side", "server_hostname", "owner", "session", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_socket", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_socket", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *sock; int server_side; PyObject *hostname_obj = Py_None; PyObject *owner = Py_None; PyObject *session = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyObject_TypeCheck(args[0], PySocketModule.Sock_Type)) { - _PyArg_BadArgument("_wrap_socket", "argument 'sock'", (PySocketModule.Sock_Type)->tp_name, args[0]); - goto exit; - } - sock = args[0]; - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } - server_side = _PyLong_AsInt(args[1]); - if (server_side == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - hostname_obj = args[2]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[3]) { - owner = args[3]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - session = args[4]; -skip_optional_kwonly: + if (!PyObject_TypeCheck(args[0], PySocketModule.Sock_Type)) { + _PyArg_BadArgument("_wrap_socket", "argument 'sock'", (PySocketModule.Sock_Type)->tp_name, args[0]); + goto exit; + } + sock = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + server_side = _PyLong_AsInt(args[1]); + if (server_side == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + hostname_obj = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + owner = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + session = args[4]; +skip_optional_kwonly: return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj, owner, session); exit: @@ -737,7 +737,7 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_bio__doc__, "\n"); #define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF \ - {"_wrap_bio", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_bio, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__}, + {"_wrap_bio", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_bio, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__}, static PyObject * _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming, @@ -750,9 +750,9 @@ _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", "owner", "session", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_bio", 0}; - PyObject *argsbuf[6]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_bio", 0}; + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; PySSLMemoryBIO *incoming; PySSLMemoryBIO *outgoing; int server_side; @@ -760,50 +760,50 @@ _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t PyObject *owner = Py_None; PyObject *session = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyObject_TypeCheck(args[0], &PySSLMemoryBIO_Type)) { - _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (&PySSLMemoryBIO_Type)->tp_name, args[0]); - goto exit; - } - incoming = (PySSLMemoryBIO *)args[0]; - if (!PyObject_TypeCheck(args[1], &PySSLMemoryBIO_Type)) { - _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (&PySSLMemoryBIO_Type)->tp_name, args[1]); - goto exit; - } - outgoing = (PySSLMemoryBIO *)args[1]; - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); + if (!args) { goto exit; } - server_side = _PyLong_AsInt(args[2]); - if (server_side == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[3]) { - hostname_obj = args[3]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[4]) { - owner = args[4]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - session = args[5]; -skip_optional_kwonly: + if (!PyObject_TypeCheck(args[0], &PySSLMemoryBIO_Type)) { + _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (&PySSLMemoryBIO_Type)->tp_name, args[0]); + goto exit; + } + incoming = (PySSLMemoryBIO *)args[0]; + if (!PyObject_TypeCheck(args[1], &PySSLMemoryBIO_Type)) { + _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (&PySSLMemoryBIO_Type)->tp_name, args[1]); + goto exit; + } + outgoing = (PySSLMemoryBIO *)args[1]; + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + server_side = _PyLong_AsInt(args[2]); + if (server_side == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + hostname_obj = args[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[4]) { + owner = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + session = args[5]; +skip_optional_kwonly: return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj, owner, session); exit: @@ -893,7 +893,7 @@ PyDoc_STRVAR(_ssl__SSLContext_get_ca_certs__doc__, "been used at least once."); #define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF \ - {"get_ca_certs", (PyCFunction)(void(*)(void))_ssl__SSLContext_get_ca_certs, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__}, + {"get_ca_certs", (PyCFunction)(void(*)(void))_ssl__SSLContext_get_ca_certs, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__}, static PyObject * _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form); @@ -903,23 +903,23 @@ _ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"binary_form", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get_ca_certs", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "get_ca_certs", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int binary_form = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - binary_form = PyObject_IsTrue(args[0]); - if (binary_form < 0) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + binary_form = PyObject_IsTrue(args[0]); + if (binary_form < 0) { + goto exit; + } +skip_optional_pos: return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form); exit: @@ -960,7 +960,7 @@ PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__, "distinguish between the two."); #define _SSL_MEMORYBIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_ssl_MemoryBIO_read, METH_FASTCALL, _ssl_MemoryBIO_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_ssl_MemoryBIO_read, METH_FASTCALL, _ssl_MemoryBIO_read__doc__}, static PyObject * _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len); @@ -971,22 +971,22 @@ _ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *const *args, Py_ssize_t narg PyObject *return_value = NULL; int len = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - len = _PyLong_AsInt(args[0]); - if (len == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + len = _PyLong_AsInt(args[0]); + if (len == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _ssl_MemoryBIO_read_impl(self, len); exit: @@ -1013,13 +1013,13 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer b = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&b, 'C')) { - _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&b, 'C')) { + _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); + goto exit; + } return_value = _ssl_MemoryBIO_write_impl(self, &b); exit: @@ -1061,7 +1061,7 @@ PyDoc_STRVAR(_ssl_RAND_add__doc__, "string. See RFC 4086."); #define _SSL_RAND_ADD_METHODDEF \ - {"RAND_add", (PyCFunction)(void(*)(void))_ssl_RAND_add, METH_FASTCALL, _ssl_RAND_add__doc__}, + {"RAND_add", (PyCFunction)(void(*)(void))_ssl_RAND_add, METH_FASTCALL, _ssl_RAND_add__doc__}, static PyObject * _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy); @@ -1073,36 +1073,36 @@ _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer view = {NULL, NULL}; double entropy; - if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) { goto exit; } - if (PyUnicode_Check(args[0])) { - Py_ssize_t len; - const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); - if (ptr == NULL) { - goto exit; - } - PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0); - } - else { /* any bytes-like object */ - if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&view, 'C')) { - _PyArg_BadArgument("RAND_add", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - entropy = PyFloat_AS_DOUBLE(args[1]); - } - else - { - entropy = PyFloat_AsDouble(args[1]); - if (entropy == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (PyUnicode_Check(args[0])) { + Py_ssize_t len; + const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len); + if (ptr == NULL) { + goto exit; + } + PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0); + } + else { /* any bytes-like object */ + if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&view, 'C')) { + _PyArg_BadArgument("RAND_add", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + entropy = PyFloat_AS_DOUBLE(args[1]); + } + else + { + entropy = PyFloat_AsDouble(args[1]); + if (entropy == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = _ssl_RAND_add_impl(module, &view, entropy); exit: @@ -1132,15 +1132,15 @@ _ssl_RAND_bytes(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int n; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - n = _PyLong_AsInt(arg); - if (n == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + n = _PyLong_AsInt(arg); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _ssl_RAND_bytes_impl(module, n); exit: @@ -1168,15 +1168,15 @@ _ssl_RAND_pseudo_bytes(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int n; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - n = _PyLong_AsInt(arg); - if (n == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + n = _PyLong_AsInt(arg); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _ssl_RAND_pseudo_bytes_impl(module, n); exit: @@ -1227,7 +1227,7 @@ _ssl_RAND_egd(PyObject *module, PyObject *arg) PyObject *return_value = NULL; PyObject *path; - if (!PyUnicode_FSConverter(arg, &path)) { + if (!PyUnicode_FSConverter(arg, &path)) { goto exit; } return_value = _ssl_RAND_egd_impl(module, path); @@ -1268,7 +1268,7 @@ PyDoc_STRVAR(_ssl_txt2obj__doc__, "long name are also matched."); #define _SSL_TXT2OBJ_METHODDEF \ - {"txt2obj", (PyCFunction)(void(*)(void))_ssl_txt2obj, METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__}, + {"txt2obj", (PyCFunction)(void(*)(void))_ssl_txt2obj, METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__}, static PyObject * _ssl_txt2obj_impl(PyObject *module, const char *txt, int name); @@ -1278,37 +1278,37 @@ _ssl_txt2obj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"txt", "name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "txt2obj", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "txt2obj", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; const char *txt; int name = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("txt2obj", "argument 'txt'", "str", args[0]); - goto exit; - } - Py_ssize_t txt_length; - txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length); - if (txt == NULL) { - goto exit; - } - if (strlen(txt) != (size_t)txt_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - name = PyObject_IsTrue(args[1]); - if (name < 0) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_pos: + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("txt2obj", "argument 'txt'", "str", args[0]); + goto exit; + } + Py_ssize_t txt_length; + txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length); + if (txt == NULL) { + goto exit; + } + if (strlen(txt) != (size_t)txt_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + name = PyObject_IsTrue(args[1]); + if (name < 0) { + goto exit; + } +skip_optional_pos: return_value = _ssl_txt2obj_impl(module, txt, name); exit: @@ -1333,15 +1333,15 @@ _ssl_nid2obj(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int nid; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nid = _PyLong_AsInt(arg); - if (nid == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + nid = _PyLong_AsInt(arg); + if (nid == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _ssl_nid2obj_impl(module, nid); exit: @@ -1363,7 +1363,7 @@ PyDoc_STRVAR(_ssl_enum_certificates__doc__, "a set of OIDs or the boolean True."); #define _SSL_ENUM_CERTIFICATES_METHODDEF \ - {"enum_certificates", (PyCFunction)(void(*)(void))_ssl_enum_certificates, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__}, + {"enum_certificates", (PyCFunction)(void(*)(void))_ssl_enum_certificates, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__}, static PyObject * _ssl_enum_certificates_impl(PyObject *module, const char *store_name); @@ -1373,27 +1373,27 @@ _ssl_enum_certificates(PyObject *module, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"store_name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "enum_certificates", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "enum_certificates", 0}; + PyObject *argsbuf[1]; const char *store_name; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("enum_certificates", "argument 'store_name'", "str", args[0]); - goto exit; - } - Py_ssize_t store_name_length; - store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); - if (store_name == NULL) { - goto exit; - } - if (strlen(store_name) != (size_t)store_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("enum_certificates", "argument 'store_name'", "str", args[0]); + goto exit; + } + Py_ssize_t store_name_length; + store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + if (store_name == NULL) { + goto exit; + } + if (strlen(store_name) != (size_t)store_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _ssl_enum_certificates_impl(module, store_name); exit: @@ -1416,7 +1416,7 @@ PyDoc_STRVAR(_ssl_enum_crls__doc__, "X509_ASN_ENCODING or PKCS_7_ASN_ENCODING."); #define _SSL_ENUM_CRLS_METHODDEF \ - {"enum_crls", (PyCFunction)(void(*)(void))_ssl_enum_crls, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__}, + {"enum_crls", (PyCFunction)(void(*)(void))_ssl_enum_crls, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__}, static PyObject * _ssl_enum_crls_impl(PyObject *module, const char *store_name); @@ -1426,27 +1426,27 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"store_name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "enum_crls", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "enum_crls", 0}; + PyObject *argsbuf[1]; const char *store_name; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("enum_crls", "argument 'store_name'", "str", args[0]); - goto exit; - } - Py_ssize_t store_name_length; - store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); - if (store_name == NULL) { - goto exit; - } - if (strlen(store_name) != (size_t)store_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("enum_crls", "argument 'store_name'", "str", args[0]); + goto exit; + } + Py_ssize_t store_name_length; + store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + if (store_name == NULL) { + goto exit; + } + if (strlen(store_name) != (size_t)store_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _ssl_enum_crls_impl(module, store_name); exit: @@ -1482,4 +1482,4 @@ exit: #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=a4aeb3f92a091c64 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a4aeb3f92a091c64 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_statisticsmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_statisticsmodule.c.h index 5ff01efddc..73b694cb2b 100644 --- a/contrib/tools/python3/src/Modules/clinic/_statisticsmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_statisticsmodule.c.h @@ -1,68 +1,68 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_statistics__normal_dist_inv_cdf__doc__, -"_normal_dist_inv_cdf($module, p, mu, sigma, /)\n" -"--\n" -"\n"); - -#define _STATISTICS__NORMAL_DIST_INV_CDF_METHODDEF \ - {"_normal_dist_inv_cdf", (PyCFunction)(void(*)(void))_statistics__normal_dist_inv_cdf, METH_FASTCALL, _statistics__normal_dist_inv_cdf__doc__}, - -static double -_statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu, - double sigma); - -static PyObject * -_statistics__normal_dist_inv_cdf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - double p; - double mu; - double sigma; - double _return_value; - - if (!_PyArg_CheckPositional("_normal_dist_inv_cdf", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_CheckExact(args[0])) { - p = PyFloat_AS_DOUBLE(args[0]); - } - else - { - p = PyFloat_AsDouble(args[0]); - if (p == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - mu = PyFloat_AS_DOUBLE(args[1]); - } - else - { - mu = PyFloat_AsDouble(args[1]); - if (mu == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[2])) { - sigma = PyFloat_AS_DOUBLE(args[2]); - } - else - { - sigma = PyFloat_AsDouble(args[2]); - if (sigma == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - _return_value = _statistics__normal_dist_inv_cdf_impl(module, p, mu, sigma); - if ((_return_value == -1.0) && PyErr_Occurred()) { - goto exit; - } - return_value = PyFloat_FromDouble(_return_value); - -exit: - return return_value; -} -/*[clinic end generated code: output=c5826928a238326c input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_statistics__normal_dist_inv_cdf__doc__, +"_normal_dist_inv_cdf($module, p, mu, sigma, /)\n" +"--\n" +"\n"); + +#define _STATISTICS__NORMAL_DIST_INV_CDF_METHODDEF \ + {"_normal_dist_inv_cdf", (PyCFunction)(void(*)(void))_statistics__normal_dist_inv_cdf, METH_FASTCALL, _statistics__normal_dist_inv_cdf__doc__}, + +static double +_statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu, + double sigma); + +static PyObject * +_statistics__normal_dist_inv_cdf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + double p; + double mu; + double sigma; + double _return_value; + + if (!_PyArg_CheckPositional("_normal_dist_inv_cdf", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_CheckExact(args[0])) { + p = PyFloat_AS_DOUBLE(args[0]); + } + else + { + p = PyFloat_AsDouble(args[0]); + if (p == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + mu = PyFloat_AS_DOUBLE(args[1]); + } + else + { + mu = PyFloat_AsDouble(args[1]); + if (mu == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[2])) { + sigma = PyFloat_AS_DOUBLE(args[2]); + } + else + { + sigma = PyFloat_AsDouble(args[2]); + if (sigma == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + _return_value = _statistics__normal_dist_inv_cdf_impl(module, p, mu, sigma); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=c5826928a238326c input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_struct.c.h b/contrib/tools/python3/src/Modules/clinic/_struct.c.h index 36c4b4046c..accf68d9e7 100644 --- a/contrib/tools/python3/src/Modules/clinic/_struct.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_struct.c.h @@ -21,17 +21,17 @@ Struct___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"format", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Struct", 0}; - PyObject *argsbuf[1]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); + static _PyArg_Parser _parser = {NULL, _keywords, "Struct", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *format; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - format = fastargs[0]; + format = fastargs[0]; return_value = Struct___init___impl((PyStructObject *)self, format); exit: @@ -61,13 +61,13 @@ Struct_unpack(PyStructObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("unpack", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack", "argument", "contiguous buffer", arg); + goto exit; + } return_value = Struct_unpack_impl(self, &buffer); exit: @@ -87,13 +87,13 @@ PyDoc_STRVAR(Struct_unpack_from__doc__, "\n" "Values are unpacked according to the format string Struct.format.\n" "\n" -"The buffer\'s size in bytes, starting at position offset, must be\n" -"at least Struct.size.\n" +"The buffer\'s size in bytes, starting at position offset, must be\n" +"at least Struct.size.\n" "\n" "See help(struct) for more on format strings."); #define STRUCT_UNPACK_FROM_METHODDEF \ - {"unpack_from", (PyCFunction)(void(*)(void))Struct_unpack_from, METH_FASTCALL|METH_KEYWORDS, Struct_unpack_from__doc__}, + {"unpack_from", (PyCFunction)(void(*)(void))Struct_unpack_from, METH_FASTCALL|METH_KEYWORDS, Struct_unpack_from__doc__}, static PyObject * Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer, @@ -104,44 +104,44 @@ Struct_unpack_from(PyStructObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"buffer", "offset", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer buffer = {NULL, NULL}; Py_ssize_t offset = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - offset = ival; - } -skip_optional_pos: + if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + offset = ival; + } +skip_optional_pos: return_value = Struct_unpack_from_impl(self, &buffer, offset); exit: @@ -204,7 +204,7 @@ calcsize(PyObject *module, PyObject *arg) PyStructObject *s_object = NULL; Py_ssize_t _return_value; - if (!cache_struct_converter(arg, &s_object)) { + if (!cache_struct_converter(arg, &s_object)) { goto exit; } _return_value = calcsize_impl(module, s_object); @@ -231,7 +231,7 @@ PyDoc_STRVAR(unpack__doc__, "See help(struct) for more on format strings."); #define UNPACK_METHODDEF \ - {"unpack", (PyCFunction)(void(*)(void))unpack, METH_FASTCALL, unpack__doc__}, + {"unpack", (PyCFunction)(void(*)(void))unpack, METH_FASTCALL, unpack__doc__}, static PyObject * unpack_impl(PyObject *module, PyStructObject *s_object, Py_buffer *buffer); @@ -243,19 +243,19 @@ unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyStructObject *s_object = NULL; Py_buffer buffer = {NULL, NULL}; - if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) { - goto exit; - } - if (!cache_struct_converter(args[0], &s_object)) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("unpack", "argument 2", "contiguous buffer", args[1]); + if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) { goto exit; } + if (!cache_struct_converter(args[0], &s_object)) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack", "argument 2", "contiguous buffer", args[1]); + goto exit; + } return_value = unpack_impl(module, s_object, &buffer); exit: @@ -280,7 +280,7 @@ PyDoc_STRVAR(unpack_from__doc__, "See help(struct) for more on format strings."); #define UNPACK_FROM_METHODDEF \ - {"unpack_from", (PyCFunction)(void(*)(void))unpack_from, METH_FASTCALL|METH_KEYWORDS, unpack_from__doc__}, + {"unpack_from", (PyCFunction)(void(*)(void))unpack_from, METH_FASTCALL|METH_KEYWORDS, unpack_from__doc__}, static PyObject * unpack_from_impl(PyObject *module, PyStructObject *s_object, @@ -291,48 +291,48 @@ unpack_from(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "buffer", "offset", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyStructObject *s_object = NULL; Py_buffer buffer = {NULL, NULL}; Py_ssize_t offset = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!cache_struct_converter(args[0], &s_object)) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[1]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - offset = ival; - } -skip_optional_pos: + if (!cache_struct_converter(args[0], &s_object)) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[1]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + offset = ival; + } +skip_optional_pos: return_value = unpack_from_impl(module, s_object, &buffer, offset); exit: @@ -358,7 +358,7 @@ PyDoc_STRVAR(iter_unpack__doc__, "Requires that the bytes length be a multiple of the format struct size."); #define ITER_UNPACK_METHODDEF \ - {"iter_unpack", (PyCFunction)(void(*)(void))iter_unpack, METH_FASTCALL, iter_unpack__doc__}, + {"iter_unpack", (PyCFunction)(void(*)(void))iter_unpack, METH_FASTCALL, iter_unpack__doc__}, static PyObject * iter_unpack_impl(PyObject *module, PyStructObject *s_object, @@ -371,13 +371,13 @@ iter_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyStructObject *s_object = NULL; PyObject *buffer; - if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) { - goto exit; - } - if (!cache_struct_converter(args[0], &s_object)) { + if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) { goto exit; } - buffer = args[1]; + if (!cache_struct_converter(args[0], &s_object)) { + goto exit; + } + buffer = args[1]; return_value = iter_unpack_impl(module, s_object, buffer); exit: @@ -386,4 +386,4 @@ exit: return return_value; } -/*[clinic end generated code: output=6a6228cfc4b7099c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6a6228cfc4b7099c input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_tkinter.c.h b/contrib/tools/python3/src/Modules/clinic/_tkinter.c.h index 73c3faeaf9..ba78fcbbaa 100644 --- a/contrib/tools/python3/src/Modules/clinic/_tkinter.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_tkinter.c.h @@ -19,19 +19,19 @@ _tkinter_tkapp_eval(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *script; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("eval", "argument", "str", arg); - goto exit; - } - Py_ssize_t script_length; - script = PyUnicode_AsUTF8AndSize(arg, &script_length); - if (script == NULL) { - goto exit; - } - if (strlen(script) != (size_t)script_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("eval", "argument", "str", arg); + goto exit; + } + Py_ssize_t script_length; + script = PyUnicode_AsUTF8AndSize(arg, &script_length); + if (script == NULL) { + goto exit; + } + if (strlen(script) != (size_t)script_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_eval_impl(self, script); exit: @@ -55,19 +55,19 @@ _tkinter_tkapp_evalfile(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *fileName; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("evalfile", "argument", "str", arg); - goto exit; - } - Py_ssize_t fileName_length; - fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length); - if (fileName == NULL) { - goto exit; - } - if (strlen(fileName) != (size_t)fileName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("evalfile", "argument", "str", arg); goto exit; } + Py_ssize_t fileName_length; + fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length); + if (fileName == NULL) { + goto exit; + } + if (strlen(fileName) != (size_t)fileName_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_evalfile_impl(self, fileName); exit: @@ -91,19 +91,19 @@ _tkinter_tkapp_record(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *script; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("record", "argument", "str", arg); - goto exit; - } - Py_ssize_t script_length; - script = PyUnicode_AsUTF8AndSize(arg, &script_length); - if (script == NULL) { - goto exit; - } - if (strlen(script) != (size_t)script_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("record", "argument", "str", arg); goto exit; } + Py_ssize_t script_length; + script = PyUnicode_AsUTF8AndSize(arg, &script_length); + if (script == NULL) { + goto exit; + } + if (strlen(script) != (size_t)script_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_record_impl(self, script); exit: @@ -127,19 +127,19 @@ _tkinter_tkapp_adderrorinfo(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *msg; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("adderrorinfo", "argument", "str", arg); - goto exit; - } - Py_ssize_t msg_length; - msg = PyUnicode_AsUTF8AndSize(arg, &msg_length); - if (msg == NULL) { - goto exit; - } - if (strlen(msg) != (size_t)msg_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("adderrorinfo", "argument", "str", arg); goto exit; } + Py_ssize_t msg_length; + msg = PyUnicode_AsUTF8AndSize(arg, &msg_length); + if (msg == NULL) { + goto exit; + } + if (strlen(msg) != (size_t)msg_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_adderrorinfo_impl(self, msg); exit: @@ -187,19 +187,19 @@ _tkinter_tkapp_exprstring(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *s; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("exprstring", "argument", "str", arg); - goto exit; - } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); - if (s == NULL) { - goto exit; - } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("exprstring", "argument", "str", arg); goto exit; } + Py_ssize_t s_length; + s = PyUnicode_AsUTF8AndSize(arg, &s_length); + if (s == NULL) { + goto exit; + } + if (strlen(s) != (size_t)s_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_exprstring_impl(self, s); exit: @@ -223,19 +223,19 @@ _tkinter_tkapp_exprlong(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *s; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("exprlong", "argument", "str", arg); - goto exit; - } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); - if (s == NULL) { - goto exit; - } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("exprlong", "argument", "str", arg); goto exit; } + Py_ssize_t s_length; + s = PyUnicode_AsUTF8AndSize(arg, &s_length); + if (s == NULL) { + goto exit; + } + if (strlen(s) != (size_t)s_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_exprlong_impl(self, s); exit: @@ -259,19 +259,19 @@ _tkinter_tkapp_exprdouble(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *s; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("exprdouble", "argument", "str", arg); - goto exit; - } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); - if (s == NULL) { - goto exit; - } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("exprdouble", "argument", "str", arg); goto exit; } + Py_ssize_t s_length; + s = PyUnicode_AsUTF8AndSize(arg, &s_length); + if (s == NULL) { + goto exit; + } + if (strlen(s) != (size_t)s_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_exprdouble_impl(self, s); exit: @@ -295,19 +295,19 @@ _tkinter_tkapp_exprboolean(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *s; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("exprboolean", "argument", "str", arg); - goto exit; - } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); - if (s == NULL) { - goto exit; - } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("exprboolean", "argument", "str", arg); goto exit; } + Py_ssize_t s_length; + s = PyUnicode_AsUTF8AndSize(arg, &s_length); + if (s == NULL) { + goto exit; + } + if (strlen(s) != (size_t)s_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_exprboolean_impl(self, s); exit: @@ -336,7 +336,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createcommand__doc__, "\n"); #define _TKINTER_TKAPP_CREATECOMMAND_METHODDEF \ - {"createcommand", (PyCFunction)(void(*)(void))_tkinter_tkapp_createcommand, METH_FASTCALL, _tkinter_tkapp_createcommand__doc__}, + {"createcommand", (PyCFunction)(void(*)(void))_tkinter_tkapp_createcommand, METH_FASTCALL, _tkinter_tkapp_createcommand__doc__}, static PyObject * _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, @@ -349,23 +349,23 @@ _tkinter_tkapp_createcommand(TkappObject *self, PyObject *const *args, Py_ssize_ const char *name; PyObject *func; - if (!_PyArg_CheckPositional("createcommand", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("createcommand", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - func = args[1]; + if (!_PyArg_CheckPositional("createcommand", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("createcommand", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + func = args[1]; return_value = _tkinter_tkapp_createcommand_impl(self, name, func); exit: @@ -389,19 +389,19 @@ _tkinter_tkapp_deletecommand(TkappObject *self, PyObject *arg) PyObject *return_value = NULL; const char *name; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("deletecommand", "argument", "str", arg); - goto exit; - } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("deletecommand", "argument", "str", arg); goto exit; } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(arg, &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = _tkinter_tkapp_deletecommand_impl(self, name); exit: @@ -416,7 +416,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createfilehandler__doc__, "\n"); #define _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF \ - {"createfilehandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createfilehandler, METH_FASTCALL, _tkinter_tkapp_createfilehandler__doc__}, + {"createfilehandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createfilehandler, METH_FASTCALL, _tkinter_tkapp_createfilehandler__doc__}, static PyObject * _tkinter_tkapp_createfilehandler_impl(TkappObject *self, PyObject *file, @@ -430,20 +430,20 @@ _tkinter_tkapp_createfilehandler(TkappObject *self, PyObject *const *args, Py_ss int mask; PyObject *func; - if (!_PyArg_CheckPositional("createfilehandler", nargs, 3, 3)) { - goto exit; - } - file = args[0]; - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (!_PyArg_CheckPositional("createfilehandler", nargs, 3, 3)) { goto exit; } - mask = _PyLong_AsInt(args[1]); - if (mask == -1 && PyErr_Occurred()) { - goto exit; - } - func = args[2]; + file = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mask = _PyLong_AsInt(args[1]); + if (mask == -1 && PyErr_Occurred()) { + goto exit; + } + func = args[2]; return_value = _tkinter_tkapp_createfilehandler_impl(self, file, mask, func); exit: @@ -487,7 +487,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createtimerhandler__doc__, "\n"); #define _TKINTER_TKAPP_CREATETIMERHANDLER_METHODDEF \ - {"createtimerhandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createtimerhandler, METH_FASTCALL, _tkinter_tkapp_createtimerhandler__doc__}, + {"createtimerhandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createtimerhandler, METH_FASTCALL, _tkinter_tkapp_createtimerhandler__doc__}, static PyObject * _tkinter_tkapp_createtimerhandler_impl(TkappObject *self, int milliseconds, @@ -500,19 +500,19 @@ _tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject *const *args, Py_s int milliseconds; PyObject *func; - if (!_PyArg_CheckPositional("createtimerhandler", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - milliseconds = _PyLong_AsInt(args[0]); - if (milliseconds == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("createtimerhandler", nargs, 2, 2)) { goto exit; } - func = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + milliseconds = _PyLong_AsInt(args[0]); + if (milliseconds == -1 && PyErr_Occurred()) { + goto exit; + } + func = args[1]; return_value = _tkinter_tkapp_createtimerhandler_impl(self, milliseconds, func); exit: @@ -525,7 +525,7 @@ PyDoc_STRVAR(_tkinter_tkapp_mainloop__doc__, "\n"); #define _TKINTER_TKAPP_MAINLOOP_METHODDEF \ - {"mainloop", (PyCFunction)(void(*)(void))_tkinter_tkapp_mainloop, METH_FASTCALL, _tkinter_tkapp_mainloop__doc__}, + {"mainloop", (PyCFunction)(void(*)(void))_tkinter_tkapp_mainloop, METH_FASTCALL, _tkinter_tkapp_mainloop__doc__}, static PyObject * _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold); @@ -536,22 +536,22 @@ _tkinter_tkapp_mainloop(TkappObject *self, PyObject *const *args, Py_ssize_t nar PyObject *return_value = NULL; int threshold = 0; - if (!_PyArg_CheckPositional("mainloop", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - threshold = _PyLong_AsInt(args[0]); - if (threshold == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("mainloop", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + threshold = _PyLong_AsInt(args[0]); + if (threshold == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _tkinter_tkapp_mainloop_impl(self, threshold); exit: @@ -564,7 +564,7 @@ PyDoc_STRVAR(_tkinter_tkapp_dooneevent__doc__, "\n"); #define _TKINTER_TKAPP_DOONEEVENT_METHODDEF \ - {"dooneevent", (PyCFunction)(void(*)(void))_tkinter_tkapp_dooneevent, METH_FASTCALL, _tkinter_tkapp_dooneevent__doc__}, + {"dooneevent", (PyCFunction)(void(*)(void))_tkinter_tkapp_dooneevent, METH_FASTCALL, _tkinter_tkapp_dooneevent__doc__}, static PyObject * _tkinter_tkapp_dooneevent_impl(TkappObject *self, int flags); @@ -575,22 +575,22 @@ _tkinter_tkapp_dooneevent(TkappObject *self, PyObject *const *args, Py_ssize_t n PyObject *return_value = NULL; int flags = 0; - if (!_PyArg_CheckPositional("dooneevent", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[0]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("dooneevent", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[0]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _tkinter_tkapp_dooneevent_impl(self, flags); exit: @@ -674,7 +674,7 @@ PyDoc_STRVAR(_tkinter__flatten__doc__, {"_flatten", (PyCFunction)_tkinter__flatten, METH_O, _tkinter__flatten__doc__}, PyDoc_STRVAR(_tkinter_create__doc__, -"create($module, screenName=None, baseName=\'\', className=\'Tk\',\n" +"create($module, screenName=None, baseName=\'\', className=\'Tk\',\n" " interactive=False, wantobjects=False, wantTk=True, sync=False,\n" " use=None, /)\n" "--\n" @@ -689,7 +689,7 @@ PyDoc_STRVAR(_tkinter_create__doc__, " if not None, then pass -use to wish"); #define _TKINTER_CREATE_METHODDEF \ - {"create", (PyCFunction)(void(*)(void))_tkinter_create, METH_FASTCALL, _tkinter_create__doc__}, + {"create", (PyCFunction)(void(*)(void))_tkinter_create, METH_FASTCALL, _tkinter_create__doc__}, static PyObject * _tkinter_create_impl(PyObject *module, const char *screenName, @@ -702,7 +702,7 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; const char *screenName = NULL; - const char *baseName = ""; + const char *baseName = ""; const char *className = "Tk"; int interactive = 0; int wantobjects = 0; @@ -710,132 +710,132 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int sync = 0; const char *use = NULL; - if (!_PyArg_CheckPositional("create", nargs, 0, 8)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (args[0] == Py_None) { - screenName = NULL; - } - else if (PyUnicode_Check(args[0])) { - Py_ssize_t screenName_length; - screenName = PyUnicode_AsUTF8AndSize(args[0], &screenName_length); - if (screenName == NULL) { - goto exit; - } - if (strlen(screenName) != (size_t)screenName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("create", "argument 1", "str or None", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("create", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t baseName_length; - baseName = PyUnicode_AsUTF8AndSize(args[1], &baseName_length); - if (baseName == NULL) { - goto exit; - } - if (strlen(baseName) != (size_t)baseName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("create", "argument 3", "str", args[2]); - goto exit; - } - Py_ssize_t className_length; - className = PyUnicode_AsUTF8AndSize(args[2], &className_length); - if (className == NULL) { - goto exit; - } - if (strlen(className) != (size_t)className_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - interactive = _PyLong_AsInt(args[3]); - if (interactive == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 5) { - goto skip_optional; - } - if (PyFloat_Check(args[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - wantobjects = _PyLong_AsInt(args[4]); - if (wantobjects == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 6) { - goto skip_optional; - } - if (PyFloat_Check(args[5])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - wantTk = _PyLong_AsInt(args[5]); - if (wantTk == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 7) { - goto skip_optional; - } - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - sync = _PyLong_AsInt(args[6]); - if (sync == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 8) { - goto skip_optional; - } - if (args[7] == Py_None) { - use = NULL; - } - else if (PyUnicode_Check(args[7])) { - Py_ssize_t use_length; - use = PyUnicode_AsUTF8AndSize(args[7], &use_length); - if (use == NULL) { - goto exit; - } - if (strlen(use) != (size_t)use_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("create", "argument 8", "str or None", args[7]); - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("create", nargs, 0, 8)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (args[0] == Py_None) { + screenName = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t screenName_length; + screenName = PyUnicode_AsUTF8AndSize(args[0], &screenName_length); + if (screenName == NULL) { + goto exit; + } + if (strlen(screenName) != (size_t)screenName_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("create", "argument 1", "str or None", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("create", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t baseName_length; + baseName = PyUnicode_AsUTF8AndSize(args[1], &baseName_length); + if (baseName == NULL) { + goto exit; + } + if (strlen(baseName) != (size_t)baseName_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("create", "argument 3", "str", args[2]); + goto exit; + } + Py_ssize_t className_length; + className = PyUnicode_AsUTF8AndSize(args[2], &className_length); + if (className == NULL) { + goto exit; + } + if (strlen(className) != (size_t)className_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + interactive = _PyLong_AsInt(args[3]); + if (interactive == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 5) { + goto skip_optional; + } + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wantobjects = _PyLong_AsInt(args[4]); + if (wantobjects == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 6) { + goto skip_optional; + } + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wantTk = _PyLong_AsInt(args[5]); + if (wantTk == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 7) { + goto skip_optional; + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + sync = _PyLong_AsInt(args[6]); + if (sync == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 8) { + goto skip_optional; + } + if (args[7] == Py_None) { + use = NULL; + } + else if (PyUnicode_Check(args[7])) { + Py_ssize_t use_length; + use = PyUnicode_AsUTF8AndSize(args[7], &use_length); + if (use == NULL) { + goto exit; + } + if (strlen(use) != (size_t)use_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("create", "argument 8", "str or None", args[7]); + goto exit; + } +skip_optional: return_value = _tkinter_create_impl(module, screenName, baseName, className, interactive, wantobjects, wantTk, sync, use); exit: @@ -862,15 +862,15 @@ _tkinter_setbusywaitinterval(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int new_val; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - new_val = _PyLong_AsInt(arg); - if (new_val == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + new_val = _PyLong_AsInt(arg); + if (new_val == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _tkinter_setbusywaitinterval_impl(module, new_val); exit: @@ -912,4 +912,4 @@ exit: #ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */ -/*[clinic end generated code: output=492b8b833fe54bc9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=492b8b833fe54bc9 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_tracemalloc.c.h b/contrib/tools/python3/src/Modules/clinic/_tracemalloc.c.h index 049cacd832..53757ee698 100644 --- a/contrib/tools/python3/src/Modules/clinic/_tracemalloc.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_tracemalloc.c.h @@ -84,7 +84,7 @@ PyDoc_STRVAR(_tracemalloc_start__doc__, "trace to nframe."); #define _TRACEMALLOC_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_tracemalloc_start, METH_FASTCALL, _tracemalloc_start__doc__}, + {"start", (PyCFunction)(void(*)(void))_tracemalloc_start, METH_FASTCALL, _tracemalloc_start__doc__}, static PyObject * _tracemalloc_start_impl(PyObject *module, int nframe); @@ -95,22 +95,22 @@ _tracemalloc_start(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; int nframe = 1; - if (!_PyArg_CheckPositional("start", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("start", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nframe = _PyLong_AsInt(args[0]); - if (nframe == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nframe = _PyLong_AsInt(args[0]); + if (nframe == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _tracemalloc_start_impl(module, nframe); exit: @@ -197,24 +197,24 @@ _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _tracemalloc_get_traced_memory_impl(module); } - -PyDoc_STRVAR(_tracemalloc_reset_peak__doc__, -"reset_peak($module, /)\n" -"--\n" -"\n" -"Set the peak size of memory blocks traced by tracemalloc to the current size.\n" -"\n" -"Do nothing if the tracemalloc module is not tracing memory allocations."); - -#define _TRACEMALLOC_RESET_PEAK_METHODDEF \ - {"reset_peak", (PyCFunction)_tracemalloc_reset_peak, METH_NOARGS, _tracemalloc_reset_peak__doc__}, - -static PyObject * -_tracemalloc_reset_peak_impl(PyObject *module); - -static PyObject * -_tracemalloc_reset_peak(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _tracemalloc_reset_peak_impl(module); -} -/*[clinic end generated code: output=a130117b1af821da input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_tracemalloc_reset_peak__doc__, +"reset_peak($module, /)\n" +"--\n" +"\n" +"Set the peak size of memory blocks traced by tracemalloc to the current size.\n" +"\n" +"Do nothing if the tracemalloc module is not tracing memory allocations."); + +#define _TRACEMALLOC_RESET_PEAK_METHODDEF \ + {"reset_peak", (PyCFunction)_tracemalloc_reset_peak, METH_NOARGS, _tracemalloc_reset_peak__doc__}, + +static PyObject * +_tracemalloc_reset_peak_impl(PyObject *module); + +static PyObject * +_tracemalloc_reset_peak(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _tracemalloc_reset_peak_impl(module); +} +/*[clinic end generated code: output=a130117b1af821da input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_weakref.c.h b/contrib/tools/python3/src/Modules/clinic/_weakref.c.h index c3a908fa6a..46cb603ef0 100644 --- a/contrib/tools/python3/src/Modules/clinic/_weakref.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_weakref.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(_weakref__remove_dead_weakref__doc__, "Atomically remove key from dict if it points to a dead weakref."); #define _WEAKREF__REMOVE_DEAD_WEAKREF_METHODDEF \ - {"_remove_dead_weakref", (PyCFunction)(void(*)(void))_weakref__remove_dead_weakref, METH_FASTCALL, _weakref__remove_dead_weakref__doc__}, + {"_remove_dead_weakref", (PyCFunction)(void(*)(void))_weakref__remove_dead_weakref, METH_FASTCALL, _weakref__remove_dead_weakref__doc__}, static PyObject * _weakref__remove_dead_weakref_impl(PyObject *module, PyObject *dct, @@ -50,18 +50,18 @@ _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_ PyObject *dct; PyObject *key; - if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) { goto exit; } - if (!PyDict_Check(args[0])) { - _PyArg_BadArgument("_remove_dead_weakref", "argument 1", "dict", args[0]); - goto exit; - } - dct = args[0]; - key = args[1]; + if (!PyDict_Check(args[0])) { + _PyArg_BadArgument("_remove_dead_weakref", "argument 1", "dict", args[0]); + goto exit; + } + dct = args[0]; + key = args[1]; return_value = _weakref__remove_dead_weakref_impl(module, dct, key); exit: return return_value; } -/*[clinic end generated code: output=c543dc2cd6ece975 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c543dc2cd6ece975 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/_winapi.c.h b/contrib/tools/python3/src/Modules/clinic/_winapi.c.h index e21f2bc2b6..b87ecd32cc 100644 --- a/contrib/tools/python3/src/Modules/clinic/_winapi.c.h +++ b/contrib/tools/python3/src/Modules/clinic/_winapi.c.h @@ -19,8 +19,8 @@ _winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg) PyObject *return_value = NULL; int wait; - wait = PyObject_IsTrue(arg); - if (wait < 0) { + wait = PyObject_IsTrue(arg); + if (wait < 0) { goto exit; } return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait); @@ -96,7 +96,7 @@ PyDoc_STRVAR(_winapi_ConnectNamedPipe__doc__, "\n"); #define _WINAPI_CONNECTNAMEDPIPE_METHODDEF \ - {"ConnectNamedPipe", (PyCFunction)(void(*)(void))_winapi_ConnectNamedPipe, METH_FASTCALL|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__}, + {"ConnectNamedPipe", (PyCFunction)(void(*)(void))_winapi_ConnectNamedPipe, METH_FASTCALL|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__}, static PyObject * _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle, @@ -129,7 +129,7 @@ PyDoc_STRVAR(_winapi_CreateFile__doc__, "\n"); #define _WINAPI_CREATEFILE_METHODDEF \ - {"CreateFile", (PyCFunction)(void(*)(void))_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__}, + {"CreateFile", (PyCFunction)(void(*)(void))_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__}, static HANDLE _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name, @@ -168,57 +168,57 @@ exit: return return_value; } -PyDoc_STRVAR(_winapi_CreateFileMapping__doc__, -"CreateFileMapping($module, file_handle, security_attributes, protect,\n" -" max_size_high, max_size_low, name, /)\n" -"--\n" -"\n"); - -#define _WINAPI_CREATEFILEMAPPING_METHODDEF \ - {"CreateFileMapping", (PyCFunction)(void(*)(void))_winapi_CreateFileMapping, METH_FASTCALL, _winapi_CreateFileMapping__doc__}, - -static HANDLE -_winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle, - LPSECURITY_ATTRIBUTES security_attributes, - DWORD protect, DWORD max_size_high, - DWORD max_size_low, LPCWSTR name); - -static PyObject * -_winapi_CreateFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HANDLE file_handle; - LPSECURITY_ATTRIBUTES security_attributes; - DWORD protect; - DWORD max_size_high; - DWORD max_size_low; - LPCWSTR name; - HANDLE _return_value; - - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_POINTER "kkku:CreateFileMapping", - &file_handle, &security_attributes, &protect, &max_size_high, &max_size_low, &name)) { - goto exit; - } - _return_value = _winapi_CreateFileMapping_impl(module, file_handle, security_attributes, protect, max_size_high, max_size_low, name); - if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { - goto exit; - } - if (_return_value == NULL) { - Py_RETURN_NONE; - } - return_value = HANDLE_TO_PYNUM(_return_value); - -exit: - return return_value; -} - +PyDoc_STRVAR(_winapi_CreateFileMapping__doc__, +"CreateFileMapping($module, file_handle, security_attributes, protect,\n" +" max_size_high, max_size_low, name, /)\n" +"--\n" +"\n"); + +#define _WINAPI_CREATEFILEMAPPING_METHODDEF \ + {"CreateFileMapping", (PyCFunction)(void(*)(void))_winapi_CreateFileMapping, METH_FASTCALL, _winapi_CreateFileMapping__doc__}, + +static HANDLE +_winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle, + LPSECURITY_ATTRIBUTES security_attributes, + DWORD protect, DWORD max_size_high, + DWORD max_size_low, LPCWSTR name); + +static PyObject * +_winapi_CreateFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + HANDLE file_handle; + LPSECURITY_ATTRIBUTES security_attributes; + DWORD protect; + DWORD max_size_high; + DWORD max_size_low; + LPCWSTR name; + HANDLE _return_value; + + if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_POINTER "kkku:CreateFileMapping", + &file_handle, &security_attributes, &protect, &max_size_high, &max_size_low, &name)) { + goto exit; + } + _return_value = _winapi_CreateFileMapping_impl(module, file_handle, security_attributes, protect, max_size_high, max_size_low, name); + if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { + goto exit; + } + if (_return_value == NULL) { + Py_RETURN_NONE; + } + return_value = HANDLE_TO_PYNUM(_return_value); + +exit: + return return_value; +} + PyDoc_STRVAR(_winapi_CreateJunction__doc__, "CreateJunction($module, src_path, dst_path, /)\n" "--\n" "\n"); #define _WINAPI_CREATEJUNCTION_METHODDEF \ - {"CreateJunction", (PyCFunction)(void(*)(void))_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__}, + {"CreateJunction", (PyCFunction)(void(*)(void))_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__}, static PyObject * _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path, @@ -249,7 +249,7 @@ PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__, "\n"); #define _WINAPI_CREATENAMEDPIPE_METHODDEF \ - {"CreateNamedPipe", (PyCFunction)(void(*)(void))_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__}, + {"CreateNamedPipe", (PyCFunction)(void(*)(void))_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__}, static HANDLE _winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode, @@ -301,7 +301,7 @@ PyDoc_STRVAR(_winapi_CreatePipe__doc__, "Returns a 2-tuple of handles, to the read and write ends of the pipe."); #define _WINAPI_CREATEPIPE_METHODDEF \ - {"CreatePipe", (PyCFunction)(void(*)(void))_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__}, + {"CreatePipe", (PyCFunction)(void(*)(void))_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__}, static PyObject * _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size); @@ -342,7 +342,7 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__, "process ID, and thread ID."); #define _WINAPI_CREATEPROCESS_METHODDEF \ - {"CreateProcess", (PyCFunction)(void(*)(void))_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__}, + {"CreateProcess", (PyCFunction)(void(*)(void))_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__}, static PyObject * _winapi_CreateProcess_impl(PyObject *module, @@ -390,7 +390,7 @@ PyDoc_STRVAR(_winapi_DuplicateHandle__doc__, "through both handles."); #define _WINAPI_DUPLICATEHANDLE_METHODDEF \ - {"DuplicateHandle", (PyCFunction)(void(*)(void))_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__}, + {"DuplicateHandle", (PyCFunction)(void(*)(void))_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__}, static HANDLE _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle, @@ -646,90 +646,90 @@ exit: return return_value; } -PyDoc_STRVAR(_winapi_MapViewOfFile__doc__, -"MapViewOfFile($module, file_map, desired_access, file_offset_high,\n" -" file_offset_low, number_bytes, /)\n" -"--\n" -"\n"); - -#define _WINAPI_MAPVIEWOFFILE_METHODDEF \ - {"MapViewOfFile", (PyCFunction)(void(*)(void))_winapi_MapViewOfFile, METH_FASTCALL, _winapi_MapViewOfFile__doc__}, - -static LPVOID -_winapi_MapViewOfFile_impl(PyObject *module, HANDLE file_map, - DWORD desired_access, DWORD file_offset_high, - DWORD file_offset_low, size_t number_bytes); - -static PyObject * -_winapi_MapViewOfFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HANDLE file_map; - DWORD desired_access; - DWORD file_offset_high; - DWORD file_offset_low; - size_t number_bytes; - LPVOID _return_value; - - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "kkkO&:MapViewOfFile", - &file_map, &desired_access, &file_offset_high, &file_offset_low, _PyLong_Size_t_Converter, &number_bytes)) { - goto exit; - } - _return_value = _winapi_MapViewOfFile_impl(module, file_map, desired_access, file_offset_high, file_offset_low, number_bytes); - if ((_return_value == NULL) && PyErr_Occurred()) { - goto exit; - } - return_value = HANDLE_TO_PYNUM(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_winapi_OpenFileMapping__doc__, -"OpenFileMapping($module, desired_access, inherit_handle, name, /)\n" -"--\n" -"\n"); - -#define _WINAPI_OPENFILEMAPPING_METHODDEF \ - {"OpenFileMapping", (PyCFunction)(void(*)(void))_winapi_OpenFileMapping, METH_FASTCALL, _winapi_OpenFileMapping__doc__}, - -static HANDLE -_winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access, - BOOL inherit_handle, LPCWSTR name); - -static PyObject * -_winapi_OpenFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - DWORD desired_access; - BOOL inherit_handle; - LPCWSTR name; - HANDLE _return_value; - - if (!_PyArg_ParseStack(args, nargs, "kiu:OpenFileMapping", - &desired_access, &inherit_handle, &name)) { - goto exit; - } - _return_value = _winapi_OpenFileMapping_impl(module, desired_access, inherit_handle, name); - if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { - goto exit; - } - if (_return_value == NULL) { - Py_RETURN_NONE; - } - return_value = HANDLE_TO_PYNUM(_return_value); - -exit: - return return_value; -} - +PyDoc_STRVAR(_winapi_MapViewOfFile__doc__, +"MapViewOfFile($module, file_map, desired_access, file_offset_high,\n" +" file_offset_low, number_bytes, /)\n" +"--\n" +"\n"); + +#define _WINAPI_MAPVIEWOFFILE_METHODDEF \ + {"MapViewOfFile", (PyCFunction)(void(*)(void))_winapi_MapViewOfFile, METH_FASTCALL, _winapi_MapViewOfFile__doc__}, + +static LPVOID +_winapi_MapViewOfFile_impl(PyObject *module, HANDLE file_map, + DWORD desired_access, DWORD file_offset_high, + DWORD file_offset_low, size_t number_bytes); + +static PyObject * +_winapi_MapViewOfFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + HANDLE file_map; + DWORD desired_access; + DWORD file_offset_high; + DWORD file_offset_low; + size_t number_bytes; + LPVOID _return_value; + + if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "kkkO&:MapViewOfFile", + &file_map, &desired_access, &file_offset_high, &file_offset_low, _PyLong_Size_t_Converter, &number_bytes)) { + goto exit; + } + _return_value = _winapi_MapViewOfFile_impl(module, file_map, desired_access, file_offset_high, file_offset_low, number_bytes); + if ((_return_value == NULL) && PyErr_Occurred()) { + goto exit; + } + return_value = HANDLE_TO_PYNUM(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_winapi_OpenFileMapping__doc__, +"OpenFileMapping($module, desired_access, inherit_handle, name, /)\n" +"--\n" +"\n"); + +#define _WINAPI_OPENFILEMAPPING_METHODDEF \ + {"OpenFileMapping", (PyCFunction)(void(*)(void))_winapi_OpenFileMapping, METH_FASTCALL, _winapi_OpenFileMapping__doc__}, + +static HANDLE +_winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access, + BOOL inherit_handle, LPCWSTR name); + +static PyObject * +_winapi_OpenFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + DWORD desired_access; + BOOL inherit_handle; + LPCWSTR name; + HANDLE _return_value; + + if (!_PyArg_ParseStack(args, nargs, "kiu:OpenFileMapping", + &desired_access, &inherit_handle, &name)) { + goto exit; + } + _return_value = _winapi_OpenFileMapping_impl(module, desired_access, inherit_handle, name); + if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { + goto exit; + } + if (_return_value == NULL) { + Py_RETURN_NONE; + } + return_value = HANDLE_TO_PYNUM(_return_value); + +exit: + return return_value; +} + PyDoc_STRVAR(_winapi_OpenProcess__doc__, "OpenProcess($module, desired_access, inherit_handle, process_id, /)\n" "--\n" "\n"); #define _WINAPI_OPENPROCESS_METHODDEF \ - {"OpenProcess", (PyCFunction)(void(*)(void))_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__}, + {"OpenProcess", (PyCFunction)(void(*)(void))_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__}, static HANDLE _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access, @@ -767,7 +767,7 @@ PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__, "\n"); #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \ - {"PeekNamedPipe", (PyCFunction)(void(*)(void))_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__}, + {"PeekNamedPipe", (PyCFunction)(void(*)(void))_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__}, static PyObject * _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size); @@ -795,7 +795,7 @@ PyDoc_STRVAR(_winapi_ReadFile__doc__, "\n"); #define _WINAPI_READFILE_METHODDEF \ - {"ReadFile", (PyCFunction)(void(*)(void))_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__}, + {"ReadFile", (PyCFunction)(void(*)(void))_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__}, static PyObject * _winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size, @@ -828,7 +828,7 @@ PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__, "\n"); #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \ - {"SetNamedPipeHandleState", (PyCFunction)(void(*)(void))_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__}, + {"SetNamedPipeHandleState", (PyCFunction)(void(*)(void))_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__}, static PyObject * _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe, @@ -862,7 +862,7 @@ PyDoc_STRVAR(_winapi_TerminateProcess__doc__, "Terminate the specified process and all of its threads."); #define _WINAPI_TERMINATEPROCESS_METHODDEF \ - {"TerminateProcess", (PyCFunction)(void(*)(void))_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__}, + {"TerminateProcess", (PyCFunction)(void(*)(void))_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__}, static PyObject * _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle, @@ -885,44 +885,44 @@ exit: return return_value; } -PyDoc_STRVAR(_winapi_VirtualQuerySize__doc__, -"VirtualQuerySize($module, address, /)\n" -"--\n" -"\n"); - -#define _WINAPI_VIRTUALQUERYSIZE_METHODDEF \ - {"VirtualQuerySize", (PyCFunction)_winapi_VirtualQuerySize, METH_O, _winapi_VirtualQuerySize__doc__}, - -static size_t -_winapi_VirtualQuerySize_impl(PyObject *module, LPCVOID address); - -static PyObject * -_winapi_VirtualQuerySize(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - LPCVOID address; - size_t _return_value; - - if (!PyArg_Parse(arg, "" F_POINTER ":VirtualQuerySize", &address)) { - goto exit; - } - _return_value = _winapi_VirtualQuerySize_impl(module, address); - if ((_return_value == (size_t)-1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromSize_t(_return_value); - -exit: - return return_value; -} - +PyDoc_STRVAR(_winapi_VirtualQuerySize__doc__, +"VirtualQuerySize($module, address, /)\n" +"--\n" +"\n"); + +#define _WINAPI_VIRTUALQUERYSIZE_METHODDEF \ + {"VirtualQuerySize", (PyCFunction)_winapi_VirtualQuerySize, METH_O, _winapi_VirtualQuerySize__doc__}, + +static size_t +_winapi_VirtualQuerySize_impl(PyObject *module, LPCVOID address); + +static PyObject * +_winapi_VirtualQuerySize(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + LPCVOID address; + size_t _return_value; + + if (!PyArg_Parse(arg, "" F_POINTER ":VirtualQuerySize", &address)) { + goto exit; + } + _return_value = _winapi_VirtualQuerySize_impl(module, address); + if ((_return_value == (size_t)-1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromSize_t(_return_value); + +exit: + return return_value; +} + PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__, "WaitNamedPipe($module, name, timeout, /)\n" "--\n" "\n"); #define _WINAPI_WAITNAMEDPIPE_METHODDEF \ - {"WaitNamedPipe", (PyCFunction)(void(*)(void))_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__}, + {"WaitNamedPipe", (PyCFunction)(void(*)(void))_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__}, static PyObject * _winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout); @@ -951,7 +951,7 @@ PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__, "\n"); #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \ - {"WaitForMultipleObjects", (PyCFunction)(void(*)(void))_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__}, + {"WaitForMultipleObjects", (PyCFunction)(void(*)(void))_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__}, static PyObject * _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, @@ -986,7 +986,7 @@ PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__, "in milliseconds."); #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \ - {"WaitForSingleObject", (PyCFunction)(void(*)(void))_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__}, + {"WaitForSingleObject", (PyCFunction)(void(*)(void))_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__}, static long _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle, @@ -1020,7 +1020,7 @@ PyDoc_STRVAR(_winapi_WriteFile__doc__, "\n"); #define _WINAPI_WRITEFILE_METHODDEF \ - {"WriteFile", (PyCFunction)(void(*)(void))_winapi_WriteFile, METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__}, + {"WriteFile", (PyCFunction)(void(*)(void))_winapi_WriteFile, METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__}, static PyObject * _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer, @@ -1070,7 +1070,7 @@ PyDoc_STRVAR(_winapi_GetFileType__doc__, "\n"); #define _WINAPI_GETFILETYPE_METHODDEF \ - {"GetFileType", (PyCFunction)(void(*)(void))_winapi_GetFileType, METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__}, + {"GetFileType", (PyCFunction)(void(*)(void))_winapi_GetFileType, METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__}, static DWORD _winapi_GetFileType_impl(PyObject *module, HANDLE handle); @@ -1097,4 +1097,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P exit: return return_value; } -/*[clinic end generated code: output=f3897898ea1da99d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f3897898ea1da99d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h index 005c7ffce4..81bebc4204 100644 --- a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h @@ -65,7 +65,7 @@ PyDoc_STRVAR(array_array_pop__doc__, "i defaults to -1."); #define ARRAY_ARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))array_array_pop, METH_FASTCALL, array_array_pop__doc__}, + {"pop", (PyCFunction)(void(*)(void))array_array_pop, METH_FASTCALL, array_array_pop__doc__}, static PyObject * array_array_pop_impl(arrayobject *self, Py_ssize_t i); @@ -76,30 +76,30 @@ array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t i = -1; - if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - i = ival; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + i = ival; + } +skip_optional: return_value = array_array_pop_impl(self, i); exit: @@ -122,7 +122,7 @@ PyDoc_STRVAR(array_array_insert__doc__, "Insert a new item v into the array before position i."); #define ARRAY_ARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))array_array_insert, METH_FASTCALL, array_array_insert__doc__}, + {"insert", (PyCFunction)(void(*)(void))array_array_insert, METH_FASTCALL, array_array_insert__doc__}, static PyObject * array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v); @@ -134,27 +134,27 @@ array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t i; PyObject *v; - if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - i = ival; - } - v = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + i = ival; + } + v = args[1]; return_value = array_array_insert_impl(self, i, v); exit: @@ -237,7 +237,7 @@ PyDoc_STRVAR(array_array_fromfile__doc__, "Read n objects from the file object f and append them to the end of the array."); #define ARRAY_ARRAY_FROMFILE_METHODDEF \ - {"fromfile", (PyCFunction)(void(*)(void))array_array_fromfile, METH_FASTCALL, array_array_fromfile__doc__}, + {"fromfile", (PyCFunction)(void(*)(void))array_array_fromfile, METH_FASTCALL, array_array_fromfile__doc__}, static PyObject * array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n); @@ -249,27 +249,27 @@ array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *f; Py_ssize_t n; - if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) { - goto exit; - } - f = args[0]; - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) { goto exit; } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - n = ival; - } + f = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + n = ival; + } return_value = array_array_fromfile_impl(self, f, n); exit: @@ -316,7 +316,7 @@ PyDoc_STRVAR(array_array_frombytes__doc__, "frombytes($self, buffer, /)\n" "--\n" "\n" -"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method."); +"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method."); #define ARRAY_ARRAY_FROMBYTES_METHODDEF \ {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__}, @@ -330,13 +330,13 @@ array_array_frombytes(arrayobject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg); + goto exit; + } return_value = array_array_frombytes_impl(self, &buffer); exit: @@ -380,23 +380,23 @@ PyDoc_STRVAR(array_array_fromunicode__doc__, {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__}, static PyObject * -array_array_fromunicode_impl(arrayobject *self, PyObject *ustr); +array_array_fromunicode_impl(arrayobject *self, PyObject *ustr); static PyObject * array_array_fromunicode(arrayobject *self, PyObject *arg) { PyObject *return_value = NULL; - PyObject *ustr; + PyObject *ustr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("fromunicode", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("fromunicode", "argument", "str", arg); goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - ustr = arg; - return_value = array_array_fromunicode_impl(self, ustr); + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + ustr = arg; + return_value = array_array_fromunicode_impl(self, ustr); exit: return return_value; @@ -450,7 +450,7 @@ PyDoc_STRVAR(array__array_reconstructor__doc__, "Internal. Used for pickling support."); #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \ - {"_array_reconstructor", (PyCFunction)(void(*)(void))array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__}, + {"_array_reconstructor", (PyCFunction)(void(*)(void))array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__}, static PyObject * array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype, @@ -467,32 +467,32 @@ array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t n enum machine_format_code mformat_code; PyObject *items; - if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) { - goto exit; - } - arraytype = (PyTypeObject *)args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1])) { - goto exit; - } - if (PyUnicode_GET_LENGTH(args[1]) != 1) { - _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]); - goto exit; - } - typecode = PyUnicode_READ_CHAR(args[1], 0); - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mformat_code = _PyLong_AsInt(args[2]); - if (mformat_code == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) { goto exit; } - items = args[3]; + arraytype = (PyTypeObject *)args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1])) { + goto exit; + } + if (PyUnicode_GET_LENGTH(args[1]) != 1) { + _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]); + goto exit; + } + typecode = PyUnicode_READ_CHAR(args[1], 0); + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mformat_code = _PyLong_AsInt(args[2]); + if (mformat_code == -1 && PyErr_Occurred()) { + goto exit; + } + items = args[3]; return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items); exit: @@ -534,4 +534,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__, #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, -/*[clinic end generated code: output=485e848d1f3d05e7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=485e848d1f3d05e7 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/audioop.c.h b/contrib/tools/python3/src/Modules/clinic/audioop.c.h index 8745533eeb..a14d879b9d 100644 --- a/contrib/tools/python3/src/Modules/clinic/audioop.c.h +++ b/contrib/tools/python3/src/Modules/clinic/audioop.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(audioop_getsample__doc__, "Return the value of sample index from the fragment."); #define AUDIOOP_GETSAMPLE_METHODDEF \ - {"getsample", (PyCFunction)(void(*)(void))audioop_getsample, METH_FASTCALL, audioop_getsample__doc__}, + {"getsample", (PyCFunction)(void(*)(void))audioop_getsample, METH_FASTCALL, audioop_getsample__doc__}, static PyObject * audioop_getsample_impl(PyObject *module, Py_buffer *fragment, int width, @@ -23,42 +23,42 @@ audioop_getsample(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; Py_ssize_t index; - if (!_PyArg_CheckPositional("getsample", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("getsample", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - index = ival; - } + if (!_PyArg_CheckPositional("getsample", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("getsample", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + index = ival; + } return_value = audioop_getsample_impl(module, &fragment, width, index); exit: @@ -77,7 +77,7 @@ PyDoc_STRVAR(audioop_max__doc__, "Return the maximum of the absolute value of all samples in a fragment."); #define AUDIOOP_MAX_METHODDEF \ - {"max", (PyCFunction)(void(*)(void))audioop_max, METH_FASTCALL, audioop_max__doc__}, + {"max", (PyCFunction)(void(*)(void))audioop_max, METH_FASTCALL, audioop_max__doc__}, static PyObject * audioop_max_impl(PyObject *module, Py_buffer *fragment, int width); @@ -89,25 +89,25 @@ audioop_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("max", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("max", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("max", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("max", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_max_impl(module, &fragment, width); exit: @@ -126,7 +126,7 @@ PyDoc_STRVAR(audioop_minmax__doc__, "Return the minimum and maximum values of all samples in the sound fragment."); #define AUDIOOP_MINMAX_METHODDEF \ - {"minmax", (PyCFunction)(void(*)(void))audioop_minmax, METH_FASTCALL, audioop_minmax__doc__}, + {"minmax", (PyCFunction)(void(*)(void))audioop_minmax, METH_FASTCALL, audioop_minmax__doc__}, static PyObject * audioop_minmax_impl(PyObject *module, Py_buffer *fragment, int width); @@ -138,25 +138,25 @@ audioop_minmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("minmax", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("minmax", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("minmax", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("minmax", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_minmax_impl(module, &fragment, width); exit: @@ -175,7 +175,7 @@ PyDoc_STRVAR(audioop_avg__doc__, "Return the average over all samples in the fragment."); #define AUDIOOP_AVG_METHODDEF \ - {"avg", (PyCFunction)(void(*)(void))audioop_avg, METH_FASTCALL, audioop_avg__doc__}, + {"avg", (PyCFunction)(void(*)(void))audioop_avg, METH_FASTCALL, audioop_avg__doc__}, static PyObject * audioop_avg_impl(PyObject *module, Py_buffer *fragment, int width); @@ -187,25 +187,25 @@ audioop_avg(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("avg", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("avg", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("avg", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("avg", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_avg_impl(module, &fragment, width); exit: @@ -224,7 +224,7 @@ PyDoc_STRVAR(audioop_rms__doc__, "Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n)."); #define AUDIOOP_RMS_METHODDEF \ - {"rms", (PyCFunction)(void(*)(void))audioop_rms, METH_FASTCALL, audioop_rms__doc__}, + {"rms", (PyCFunction)(void(*)(void))audioop_rms, METH_FASTCALL, audioop_rms__doc__}, static PyObject * audioop_rms_impl(PyObject *module, Py_buffer *fragment, int width); @@ -236,25 +236,25 @@ audioop_rms(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("rms", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("rms", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("rms", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("rms", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_rms_impl(module, &fragment, width); exit: @@ -273,7 +273,7 @@ PyDoc_STRVAR(audioop_findfit__doc__, "Try to match reference as well as possible to a portion of fragment."); #define AUDIOOP_FINDFIT_METHODDEF \ - {"findfit", (PyCFunction)(void(*)(void))audioop_findfit, METH_FASTCALL, audioop_findfit__doc__}, + {"findfit", (PyCFunction)(void(*)(void))audioop_findfit, METH_FASTCALL, audioop_findfit__doc__}, static PyObject * audioop_findfit_impl(PyObject *module, Py_buffer *fragment, @@ -286,23 +286,23 @@ audioop_findfit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; Py_buffer reference = {NULL, NULL}; - if (!_PyArg_CheckPositional("findfit", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("findfit", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&reference, 'C')) { - _PyArg_BadArgument("findfit", "argument 2", "contiguous buffer", args[1]); - goto exit; - } + if (!_PyArg_CheckPositional("findfit", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("findfit", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&reference, 'C')) { + _PyArg_BadArgument("findfit", "argument 2", "contiguous buffer", args[1]); + goto exit; + } return_value = audioop_findfit_impl(module, &fragment, &reference); exit: @@ -325,7 +325,7 @@ PyDoc_STRVAR(audioop_findfactor__doc__, "Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal."); #define AUDIOOP_FINDFACTOR_METHODDEF \ - {"findfactor", (PyCFunction)(void(*)(void))audioop_findfactor, METH_FASTCALL, audioop_findfactor__doc__}, + {"findfactor", (PyCFunction)(void(*)(void))audioop_findfactor, METH_FASTCALL, audioop_findfactor__doc__}, static PyObject * audioop_findfactor_impl(PyObject *module, Py_buffer *fragment, @@ -338,23 +338,23 @@ audioop_findfactor(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; Py_buffer reference = {NULL, NULL}; - if (!_PyArg_CheckPositional("findfactor", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("findfactor", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&reference, 'C')) { - _PyArg_BadArgument("findfactor", "argument 2", "contiguous buffer", args[1]); - goto exit; - } + if (!_PyArg_CheckPositional("findfactor", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("findfactor", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&reference, 'C')) { + _PyArg_BadArgument("findfactor", "argument 2", "contiguous buffer", args[1]); + goto exit; + } return_value = audioop_findfactor_impl(module, &fragment, &reference); exit: @@ -377,7 +377,7 @@ PyDoc_STRVAR(audioop_findmax__doc__, "Search fragment for a slice of specified number of samples with maximum energy."); #define AUDIOOP_FINDMAX_METHODDEF \ - {"findmax", (PyCFunction)(void(*)(void))audioop_findmax, METH_FASTCALL, audioop_findmax__doc__}, + {"findmax", (PyCFunction)(void(*)(void))audioop_findmax, METH_FASTCALL, audioop_findmax__doc__}, static PyObject * audioop_findmax_impl(PyObject *module, Py_buffer *fragment, @@ -390,33 +390,33 @@ audioop_findmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; Py_ssize_t length; - if (!_PyArg_CheckPositional("findmax", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("findmax", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - length = ival; - } + if (!_PyArg_CheckPositional("findmax", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("findmax", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } return_value = audioop_findmax_impl(module, &fragment, length); exit: @@ -435,7 +435,7 @@ PyDoc_STRVAR(audioop_avgpp__doc__, "Return the average peak-peak value over all samples in the fragment."); #define AUDIOOP_AVGPP_METHODDEF \ - {"avgpp", (PyCFunction)(void(*)(void))audioop_avgpp, METH_FASTCALL, audioop_avgpp__doc__}, + {"avgpp", (PyCFunction)(void(*)(void))audioop_avgpp, METH_FASTCALL, audioop_avgpp__doc__}, static PyObject * audioop_avgpp_impl(PyObject *module, Py_buffer *fragment, int width); @@ -447,25 +447,25 @@ audioop_avgpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("avgpp", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("avgpp", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("avgpp", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("avgpp", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_avgpp_impl(module, &fragment, width); exit: @@ -484,7 +484,7 @@ PyDoc_STRVAR(audioop_maxpp__doc__, "Return the maximum peak-peak value in the sound fragment."); #define AUDIOOP_MAXPP_METHODDEF \ - {"maxpp", (PyCFunction)(void(*)(void))audioop_maxpp, METH_FASTCALL, audioop_maxpp__doc__}, + {"maxpp", (PyCFunction)(void(*)(void))audioop_maxpp, METH_FASTCALL, audioop_maxpp__doc__}, static PyObject * audioop_maxpp_impl(PyObject *module, Py_buffer *fragment, int width); @@ -496,25 +496,25 @@ audioop_maxpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("maxpp", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("maxpp", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("maxpp", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("maxpp", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_maxpp_impl(module, &fragment, width); exit: @@ -533,7 +533,7 @@ PyDoc_STRVAR(audioop_cross__doc__, "Return the number of zero crossings in the fragment passed as an argument."); #define AUDIOOP_CROSS_METHODDEF \ - {"cross", (PyCFunction)(void(*)(void))audioop_cross, METH_FASTCALL, audioop_cross__doc__}, + {"cross", (PyCFunction)(void(*)(void))audioop_cross, METH_FASTCALL, audioop_cross__doc__}, static PyObject * audioop_cross_impl(PyObject *module, Py_buffer *fragment, int width); @@ -545,25 +545,25 @@ audioop_cross(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("cross", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("cross", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("cross", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("cross", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_cross_impl(module, &fragment, width); exit: @@ -582,7 +582,7 @@ PyDoc_STRVAR(audioop_mul__doc__, "Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor."); #define AUDIOOP_MUL_METHODDEF \ - {"mul", (PyCFunction)(void(*)(void))audioop_mul, METH_FASTCALL, audioop_mul__doc__}, + {"mul", (PyCFunction)(void(*)(void))audioop_mul, METH_FASTCALL, audioop_mul__doc__}, static PyObject * audioop_mul_impl(PyObject *module, Py_buffer *fragment, int width, @@ -596,35 +596,35 @@ audioop_mul(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; double factor; - if (!_PyArg_CheckPositional("mul", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("mul", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_CheckExact(args[2])) { - factor = PyFloat_AS_DOUBLE(args[2]); - } - else - { - factor = PyFloat_AsDouble(args[2]); - if (factor == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (!_PyArg_CheckPositional("mul", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("mul", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_CheckExact(args[2])) { + factor = PyFloat_AS_DOUBLE(args[2]); + } + else + { + factor = PyFloat_AsDouble(args[2]); + if (factor == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = audioop_mul_impl(module, &fragment, width, factor); exit: @@ -643,7 +643,7 @@ PyDoc_STRVAR(audioop_tomono__doc__, "Convert a stereo fragment to a mono fragment."); #define AUDIOOP_TOMONO_METHODDEF \ - {"tomono", (PyCFunction)(void(*)(void))audioop_tomono, METH_FASTCALL, audioop_tomono__doc__}, + {"tomono", (PyCFunction)(void(*)(void))audioop_tomono, METH_FASTCALL, audioop_tomono__doc__}, static PyObject * audioop_tomono_impl(PyObject *module, Py_buffer *fragment, int width, @@ -658,45 +658,45 @@ audioop_tomono(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double lfactor; double rfactor; - if (!_PyArg_CheckPositional("tomono", nargs, 4, 4)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("tomono", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_CheckExact(args[2])) { - lfactor = PyFloat_AS_DOUBLE(args[2]); - } - else - { - lfactor = PyFloat_AsDouble(args[2]); - if (lfactor == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[3])) { - rfactor = PyFloat_AS_DOUBLE(args[3]); - } - else - { - rfactor = PyFloat_AsDouble(args[3]); - if (rfactor == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (!_PyArg_CheckPositional("tomono", nargs, 4, 4)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("tomono", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_CheckExact(args[2])) { + lfactor = PyFloat_AS_DOUBLE(args[2]); + } + else + { + lfactor = PyFloat_AsDouble(args[2]); + if (lfactor == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[3])) { + rfactor = PyFloat_AS_DOUBLE(args[3]); + } + else + { + rfactor = PyFloat_AsDouble(args[3]); + if (rfactor == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor); exit: @@ -715,7 +715,7 @@ PyDoc_STRVAR(audioop_tostereo__doc__, "Generate a stereo fragment from a mono fragment."); #define AUDIOOP_TOSTEREO_METHODDEF \ - {"tostereo", (PyCFunction)(void(*)(void))audioop_tostereo, METH_FASTCALL, audioop_tostereo__doc__}, + {"tostereo", (PyCFunction)(void(*)(void))audioop_tostereo, METH_FASTCALL, audioop_tostereo__doc__}, static PyObject * audioop_tostereo_impl(PyObject *module, Py_buffer *fragment, int width, @@ -730,45 +730,45 @@ audioop_tostereo(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double lfactor; double rfactor; - if (!_PyArg_CheckPositional("tostereo", nargs, 4, 4)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("tostereo", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_CheckExact(args[2])) { - lfactor = PyFloat_AS_DOUBLE(args[2]); - } - else - { - lfactor = PyFloat_AsDouble(args[2]); - if (lfactor == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[3])) { - rfactor = PyFloat_AS_DOUBLE(args[3]); - } - else - { - rfactor = PyFloat_AsDouble(args[3]); - if (rfactor == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (!_PyArg_CheckPositional("tostereo", nargs, 4, 4)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("tostereo", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_CheckExact(args[2])) { + lfactor = PyFloat_AS_DOUBLE(args[2]); + } + else + { + lfactor = PyFloat_AsDouble(args[2]); + if (lfactor == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[3])) { + rfactor = PyFloat_AS_DOUBLE(args[3]); + } + else + { + rfactor = PyFloat_AsDouble(args[3]); + if (rfactor == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor); exit: @@ -787,7 +787,7 @@ PyDoc_STRVAR(audioop_add__doc__, "Return a fragment which is the addition of the two samples passed as parameters."); #define AUDIOOP_ADD_METHODDEF \ - {"add", (PyCFunction)(void(*)(void))audioop_add, METH_FASTCALL, audioop_add__doc__}, + {"add", (PyCFunction)(void(*)(void))audioop_add, METH_FASTCALL, audioop_add__doc__}, static PyObject * audioop_add_impl(PyObject *module, Py_buffer *fragment1, @@ -801,32 +801,32 @@ audioop_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment2 = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("add", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment1, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment1, 'C')) { - _PyArg_BadArgument("add", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &fragment2, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment2, 'C')) { - _PyArg_BadArgument("add", "argument 2", "contiguous buffer", args[1]); - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[2]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("add", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment1, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment1, 'C')) { + _PyArg_BadArgument("add", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &fragment2, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment2, 'C')) { + _PyArg_BadArgument("add", "argument 2", "contiguous buffer", args[1]); + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[2]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_add_impl(module, &fragment1, &fragment2, width); exit: @@ -849,7 +849,7 @@ PyDoc_STRVAR(audioop_bias__doc__, "Return a fragment that is the original fragment with a bias added to each sample."); #define AUDIOOP_BIAS_METHODDEF \ - {"bias", (PyCFunction)(void(*)(void))audioop_bias, METH_FASTCALL, audioop_bias__doc__}, + {"bias", (PyCFunction)(void(*)(void))audioop_bias, METH_FASTCALL, audioop_bias__doc__}, static PyObject * audioop_bias_impl(PyObject *module, Py_buffer *fragment, int width, int bias); @@ -862,34 +862,34 @@ audioop_bias(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; int bias; - if (!_PyArg_CheckPositional("bias", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("bias", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bias = _PyLong_AsInt(args[2]); - if (bias == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("bias", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("bias", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bias = _PyLong_AsInt(args[2]); + if (bias == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_bias_impl(module, &fragment, width, bias); exit: @@ -908,7 +908,7 @@ PyDoc_STRVAR(audioop_reverse__doc__, "Reverse the samples in a fragment and returns the modified fragment."); #define AUDIOOP_REVERSE_METHODDEF \ - {"reverse", (PyCFunction)(void(*)(void))audioop_reverse, METH_FASTCALL, audioop_reverse__doc__}, + {"reverse", (PyCFunction)(void(*)(void))audioop_reverse, METH_FASTCALL, audioop_reverse__doc__}, static PyObject * audioop_reverse_impl(PyObject *module, Py_buffer *fragment, int width); @@ -920,25 +920,25 @@ audioop_reverse(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("reverse", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("reverse", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("reverse", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("reverse", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_reverse_impl(module, &fragment, width); exit: @@ -957,7 +957,7 @@ PyDoc_STRVAR(audioop_byteswap__doc__, "Convert big-endian samples to little-endian and vice versa."); #define AUDIOOP_BYTESWAP_METHODDEF \ - {"byteswap", (PyCFunction)(void(*)(void))audioop_byteswap, METH_FASTCALL, audioop_byteswap__doc__}, + {"byteswap", (PyCFunction)(void(*)(void))audioop_byteswap, METH_FASTCALL, audioop_byteswap__doc__}, static PyObject * audioop_byteswap_impl(PyObject *module, Py_buffer *fragment, int width); @@ -969,25 +969,25 @@ audioop_byteswap(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("byteswap", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("byteswap", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("byteswap", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("byteswap", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_byteswap_impl(module, &fragment, width); exit: @@ -1006,7 +1006,7 @@ PyDoc_STRVAR(audioop_lin2lin__doc__, "Convert samples between 1-, 2-, 3- and 4-byte formats."); #define AUDIOOP_LIN2LIN_METHODDEF \ - {"lin2lin", (PyCFunction)(void(*)(void))audioop_lin2lin, METH_FASTCALL, audioop_lin2lin__doc__}, + {"lin2lin", (PyCFunction)(void(*)(void))audioop_lin2lin, METH_FASTCALL, audioop_lin2lin__doc__}, static PyObject * audioop_lin2lin_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1020,34 +1020,34 @@ audioop_lin2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; int newwidth; - if (!_PyArg_CheckPositional("lin2lin", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("lin2lin", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - newwidth = _PyLong_AsInt(args[2]); - if (newwidth == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("lin2lin", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("lin2lin", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + newwidth = _PyLong_AsInt(args[2]); + if (newwidth == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth); exit: @@ -1067,7 +1067,7 @@ PyDoc_STRVAR(audioop_ratecv__doc__, "Convert the frame rate of the input fragment."); #define AUDIOOP_RATECV_METHODDEF \ - {"ratecv", (PyCFunction)(void(*)(void))audioop_ratecv, METH_FASTCALL, audioop_ratecv__doc__}, + {"ratecv", (PyCFunction)(void(*)(void))audioop_ratecv, METH_FASTCALL, audioop_ratecv__doc__}, static PyObject * audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1087,78 +1087,78 @@ audioop_ratecv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int weightA = 1; int weightB = 0; - if (!_PyArg_CheckPositional("ratecv", nargs, 6, 8)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("ratecv", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nchannels = _PyLong_AsInt(args[2]); - if (nchannels == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - inrate = _PyLong_AsInt(args[3]); - if (inrate == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - outrate = _PyLong_AsInt(args[4]); - if (outrate == -1 && PyErr_Occurred()) { - goto exit; - } - state = args[5]; - if (nargs < 7) { - goto skip_optional; - } - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - weightA = _PyLong_AsInt(args[6]); - if (weightA == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 8) { - goto skip_optional; - } - if (PyFloat_Check(args[7])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - weightB = _PyLong_AsInt(args[7]); - if (weightB == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("ratecv", nargs, 6, 8)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("ratecv", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nchannels = _PyLong_AsInt(args[2]); + if (nchannels == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + inrate = _PyLong_AsInt(args[3]); + if (inrate == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + outrate = _PyLong_AsInt(args[4]); + if (outrate == -1 && PyErr_Occurred()) { + goto exit; + } + state = args[5]; + if (nargs < 7) { + goto skip_optional; + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + weightA = _PyLong_AsInt(args[6]); + if (weightA == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 8) { + goto skip_optional; + } + if (PyFloat_Check(args[7])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + weightB = _PyLong_AsInt(args[7]); + if (weightB == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB); exit: @@ -1177,7 +1177,7 @@ PyDoc_STRVAR(audioop_lin2ulaw__doc__, "Convert samples in the audio fragment to u-LAW encoding."); #define AUDIOOP_LIN2ULAW_METHODDEF \ - {"lin2ulaw", (PyCFunction)(void(*)(void))audioop_lin2ulaw, METH_FASTCALL, audioop_lin2ulaw__doc__}, + {"lin2ulaw", (PyCFunction)(void(*)(void))audioop_lin2ulaw, METH_FASTCALL, audioop_lin2ulaw__doc__}, static PyObject * audioop_lin2ulaw_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1189,25 +1189,25 @@ audioop_lin2ulaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("lin2ulaw", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("lin2ulaw", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("lin2ulaw", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("lin2ulaw", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_lin2ulaw_impl(module, &fragment, width); exit: @@ -1226,7 +1226,7 @@ PyDoc_STRVAR(audioop_ulaw2lin__doc__, "Convert sound fragments in u-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ULAW2LIN_METHODDEF \ - {"ulaw2lin", (PyCFunction)(void(*)(void))audioop_ulaw2lin, METH_FASTCALL, audioop_ulaw2lin__doc__}, + {"ulaw2lin", (PyCFunction)(void(*)(void))audioop_ulaw2lin, METH_FASTCALL, audioop_ulaw2lin__doc__}, static PyObject * audioop_ulaw2lin_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1238,25 +1238,25 @@ audioop_ulaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("ulaw2lin", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("ulaw2lin", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("ulaw2lin", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("ulaw2lin", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_ulaw2lin_impl(module, &fragment, width); exit: @@ -1275,7 +1275,7 @@ PyDoc_STRVAR(audioop_lin2alaw__doc__, "Convert samples in the audio fragment to a-LAW encoding."); #define AUDIOOP_LIN2ALAW_METHODDEF \ - {"lin2alaw", (PyCFunction)(void(*)(void))audioop_lin2alaw, METH_FASTCALL, audioop_lin2alaw__doc__}, + {"lin2alaw", (PyCFunction)(void(*)(void))audioop_lin2alaw, METH_FASTCALL, audioop_lin2alaw__doc__}, static PyObject * audioop_lin2alaw_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1287,25 +1287,25 @@ audioop_lin2alaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("lin2alaw", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("lin2alaw", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("lin2alaw", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("lin2alaw", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_lin2alaw_impl(module, &fragment, width); exit: @@ -1324,7 +1324,7 @@ PyDoc_STRVAR(audioop_alaw2lin__doc__, "Convert sound fragments in a-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ALAW2LIN_METHODDEF \ - {"alaw2lin", (PyCFunction)(void(*)(void))audioop_alaw2lin, METH_FASTCALL, audioop_alaw2lin__doc__}, + {"alaw2lin", (PyCFunction)(void(*)(void))audioop_alaw2lin, METH_FASTCALL, audioop_alaw2lin__doc__}, static PyObject * audioop_alaw2lin_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1336,25 +1336,25 @@ audioop_alaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer fragment = {NULL, NULL}; int width; - if (!_PyArg_CheckPositional("alaw2lin", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("alaw2lin", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("alaw2lin", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("alaw2lin", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } return_value = audioop_alaw2lin_impl(module, &fragment, width); exit: @@ -1373,7 +1373,7 @@ PyDoc_STRVAR(audioop_lin2adpcm__doc__, "Convert samples to 4 bit Intel/DVI ADPCM encoding."); #define AUDIOOP_LIN2ADPCM_METHODDEF \ - {"lin2adpcm", (PyCFunction)(void(*)(void))audioop_lin2adpcm, METH_FASTCALL, audioop_lin2adpcm__doc__}, + {"lin2adpcm", (PyCFunction)(void(*)(void))audioop_lin2adpcm, METH_FASTCALL, audioop_lin2adpcm__doc__}, static PyObject * audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1387,26 +1387,26 @@ audioop_lin2adpcm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; PyObject *state; - if (!_PyArg_CheckPositional("lin2adpcm", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("lin2adpcm", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - state = args[2]; + if (!_PyArg_CheckPositional("lin2adpcm", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("lin2adpcm", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + state = args[2]; return_value = audioop_lin2adpcm_impl(module, &fragment, width, state); exit: @@ -1425,7 +1425,7 @@ PyDoc_STRVAR(audioop_adpcm2lin__doc__, "Decode an Intel/DVI ADPCM coded fragment to a linear fragment."); #define AUDIOOP_ADPCM2LIN_METHODDEF \ - {"adpcm2lin", (PyCFunction)(void(*)(void))audioop_adpcm2lin, METH_FASTCALL, audioop_adpcm2lin__doc__}, + {"adpcm2lin", (PyCFunction)(void(*)(void))audioop_adpcm2lin, METH_FASTCALL, audioop_adpcm2lin__doc__}, static PyObject * audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1439,26 +1439,26 @@ audioop_adpcm2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int width; PyObject *state; - if (!_PyArg_CheckPositional("adpcm2lin", nargs, 3, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&fragment, 'C')) { - _PyArg_BadArgument("adpcm2lin", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - width = _PyLong_AsInt(args[1]); - if (width == -1 && PyErr_Occurred()) { - goto exit; - } - state = args[2]; + if (!_PyArg_CheckPositional("adpcm2lin", nargs, 3, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&fragment, 'C')) { + _PyArg_BadArgument("adpcm2lin", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + width = _PyLong_AsInt(args[1]); + if (width == -1 && PyErr_Occurred()) { + goto exit; + } + state = args[2]; return_value = audioop_adpcm2lin_impl(module, &fragment, width, state); exit: @@ -1469,4 +1469,4 @@ exit: return return_value; } -/*[clinic end generated code: output=6b4f2c597f295abc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6b4f2c597f295abc input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/binascii.c.h b/contrib/tools/python3/src/Modules/clinic/binascii.c.h index 4d02c72c47..51b465edc8 100644 --- a/contrib/tools/python3/src/Modules/clinic/binascii.c.h +++ b/contrib/tools/python3/src/Modules/clinic/binascii.c.h @@ -20,7 +20,7 @@ binascii_a2b_uu(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (!ascii_buffer_converter(arg, &data)) { + if (!ascii_buffer_converter(arg, &data)) { goto exit; } return_value = binascii_a2b_uu_impl(module, &data); @@ -40,7 +40,7 @@ PyDoc_STRVAR(binascii_b2a_uu__doc__, "Uuencode line of data."); #define BINASCII_B2A_UU_METHODDEF \ - {"b2a_uu", (PyCFunction)(void(*)(void))binascii_b2a_uu, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, + {"b2a_uu", (PyCFunction)(void(*)(void))binascii_b2a_uu, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, static PyObject * binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick); @@ -50,36 +50,36 @@ binascii_b2a_uu(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "backtick", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "b2a_uu", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_uu", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int backtick = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("b2a_uu", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - backtick = _PyLong_AsInt(args[1]); - if (backtick == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_uu", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + backtick = _PyLong_AsInt(args[1]); + if (backtick == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = binascii_b2a_uu_impl(module, &data, backtick); exit: @@ -109,7 +109,7 @@ binascii_a2b_base64(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (!ascii_buffer_converter(arg, &data)) { + if (!ascii_buffer_converter(arg, &data)) { goto exit; } return_value = binascii_a2b_base64_impl(module, &data); @@ -129,7 +129,7 @@ PyDoc_STRVAR(binascii_b2a_base64__doc__, "Base64-code line of data."); #define BINASCII_B2A_BASE64_METHODDEF \ - {"b2a_base64", (PyCFunction)(void(*)(void))binascii_b2a_base64, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, + {"b2a_base64", (PyCFunction)(void(*)(void))binascii_b2a_base64, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, static PyObject * binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline); @@ -139,36 +139,36 @@ binascii_b2a_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "newline", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "b2a_base64", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_base64", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int newline = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("b2a_base64", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - newline = _PyLong_AsInt(args[1]); - if (newline == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_base64", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + newline = _PyLong_AsInt(args[1]); + if (newline == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = binascii_b2a_base64_impl(module, &data, newline); exit: @@ -198,7 +198,7 @@ binascii_a2b_hqx(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (!ascii_buffer_converter(arg, &data)) { + if (!ascii_buffer_converter(arg, &data)) { goto exit; } return_value = binascii_a2b_hqx_impl(module, &data); @@ -229,13 +229,13 @@ binascii_rlecode_hqx(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("rlecode_hqx", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("rlecode_hqx", "argument", "contiguous buffer", arg); + goto exit; + } return_value = binascii_rlecode_hqx_impl(module, &data); exit: @@ -265,13 +265,13 @@ binascii_b2a_hqx(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("b2a_hqx", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_hqx", "argument", "contiguous buffer", arg); + goto exit; + } return_value = binascii_b2a_hqx_impl(module, &data); exit: @@ -301,13 +301,13 @@ binascii_rledecode_hqx(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("rledecode_hqx", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("rledecode_hqx", "argument", "contiguous buffer", arg); + goto exit; + } return_value = binascii_rledecode_hqx_impl(module, &data); exit: @@ -326,9 +326,9 @@ PyDoc_STRVAR(binascii_crc_hqx__doc__, "Compute CRC-CCITT incrementally."); #define BINASCII_CRC_HQX_METHODDEF \ - {"crc_hqx", (PyCFunction)(void(*)(void))binascii_crc_hqx, METH_FASTCALL, binascii_crc_hqx__doc__}, + {"crc_hqx", (PyCFunction)(void(*)(void))binascii_crc_hqx, METH_FASTCALL, binascii_crc_hqx__doc__}, -static PyObject * +static PyObject * binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc); static PyObject * @@ -338,26 +338,26 @@ binascii_crc_hqx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; unsigned int crc; - if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("crc_hqx", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (crc == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } - return_value = binascii_crc_hqx_impl(module, &data, crc); + if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("crc_hqx", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (crc == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } + return_value = binascii_crc_hqx_impl(module, &data, crc); exit: /* Cleanup for data */ @@ -375,7 +375,7 @@ PyDoc_STRVAR(binascii_crc32__doc__, "Compute CRC-32 incrementally."); #define BINASCII_CRC32_METHODDEF \ - {"crc32", (PyCFunction)(void(*)(void))binascii_crc32, METH_FASTCALL, binascii_crc32__doc__}, + {"crc32", (PyCFunction)(void(*)(void))binascii_crc32, METH_FASTCALL, binascii_crc32__doc__}, static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc); @@ -388,29 +388,29 @@ binascii_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) unsigned int crc = 0; unsigned int _return_value; - if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (crc == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (crc == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: _return_value = binascii_crc32_impl(module, &data, crc); if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { goto exit; @@ -427,78 +427,78 @@ exit: } PyDoc_STRVAR(binascii_b2a_hex__doc__, -"b2a_hex($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" +"b2a_hex($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" "--\n" "\n" "Hexadecimal representation of binary data.\n" "\n" -" sep\n" -" An optional single character or byte to separate hex bytes.\n" -" bytes_per_sep\n" -" How many bytes between separators. Positive values count from the\n" -" right, negative values count from the left.\n" -"\n" +" sep\n" +" An optional single character or byte to separate hex bytes.\n" +" bytes_per_sep\n" +" How many bytes between separators. Positive values count from the\n" +" right, negative values count from the left.\n" +"\n" "The return value is a bytes object. This function is also\n" -"available as \"hexlify()\".\n" -"\n" -"Example:\n" -">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\')\n" -"b\'b901ef\'\n" -">>> binascii.hexlify(b\'\\xb9\\x01\\xef\', \':\')\n" -"b\'b9:01:ef\'\n" -">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\', b\'_\', 2)\n" -"b\'b9_01ef\'"); +"available as \"hexlify()\".\n" +"\n" +"Example:\n" +">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\')\n" +"b\'b901ef\'\n" +">>> binascii.hexlify(b\'\\xb9\\x01\\xef\', \':\')\n" +"b\'b9:01:ef\'\n" +">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\', b\'_\', 2)\n" +"b\'b9_01ef\'"); #define BINASCII_B2A_HEX_METHODDEF \ - {"b2a_hex", (PyCFunction)(void(*)(void))binascii_b2a_hex, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, + {"b2a_hex", (PyCFunction)(void(*)(void))binascii_b2a_hex, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, static PyObject * -binascii_b2a_hex_impl(PyObject *module, Py_buffer *data, PyObject *sep, - int bytes_per_sep); +binascii_b2a_hex_impl(PyObject *module, Py_buffer *data, PyObject *sep, + int bytes_per_sep); static PyObject * -binascii_b2a_hex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +binascii_b2a_hex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "b2a_hex", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_hex", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; - PyObject *sep = NULL; - int bytes_per_sep = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("b2a_hex", "argument 'data'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - sep = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bytes_per_sep = _PyLong_AsInt(args[2]); - if (bytes_per_sep == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = binascii_b2a_hex_impl(module, &data, sep, bytes_per_sep); + PyObject *sep = NULL; + int bytes_per_sep = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_hex", "argument 'data'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + sep = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bytes_per_sep = _PyLong_AsInt(args[2]); + if (bytes_per_sep == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = binascii_b2a_hex_impl(module, &data, sep, bytes_per_sep); exit: /* Cleanup for data */ @@ -510,70 +510,70 @@ exit: } PyDoc_STRVAR(binascii_hexlify__doc__, -"hexlify($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" +"hexlify($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" "--\n" "\n" "Hexadecimal representation of binary data.\n" "\n" -" sep\n" -" An optional single character or byte to separate hex bytes.\n" -" bytes_per_sep\n" -" How many bytes between separators. Positive values count from the\n" -" right, negative values count from the left.\n" -"\n" -"The return value is a bytes object. This function is also\n" -"available as \"b2a_hex()\"."); +" sep\n" +" An optional single character or byte to separate hex bytes.\n" +" bytes_per_sep\n" +" How many bytes between separators. Positive values count from the\n" +" right, negative values count from the left.\n" +"\n" +"The return value is a bytes object. This function is also\n" +"available as \"b2a_hex()\"."); #define BINASCII_HEXLIFY_METHODDEF \ - {"hexlify", (PyCFunction)(void(*)(void))binascii_hexlify, METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, + {"hexlify", (PyCFunction)(void(*)(void))binascii_hexlify, METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, static PyObject * -binascii_hexlify_impl(PyObject *module, Py_buffer *data, PyObject *sep, - int bytes_per_sep); +binascii_hexlify_impl(PyObject *module, Py_buffer *data, PyObject *sep, + int bytes_per_sep); static PyObject * -binascii_hexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +binascii_hexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hexlify", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hexlify", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; - PyObject *sep = NULL; - int bytes_per_sep = 1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("hexlify", "argument 'data'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - sep = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bytes_per_sep = _PyLong_AsInt(args[2]); - if (bytes_per_sep == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = binascii_hexlify_impl(module, &data, sep, bytes_per_sep); + PyObject *sep = NULL; + int bytes_per_sep = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("hexlify", "argument 'data'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + sep = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bytes_per_sep = _PyLong_AsInt(args[2]); + if (bytes_per_sep == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = binascii_hexlify_impl(module, &data, sep, bytes_per_sep); exit: /* Cleanup for data */ @@ -605,7 +605,7 @@ binascii_a2b_hex(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer hexstr = {NULL, NULL}; - if (!ascii_buffer_converter(arg, &hexstr)) { + if (!ascii_buffer_converter(arg, &hexstr)) { goto exit; } return_value = binascii_a2b_hex_impl(module, &hexstr); @@ -638,7 +638,7 @@ binascii_unhexlify(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_buffer hexstr = {NULL, NULL}; - if (!ascii_buffer_converter(arg, &hexstr)) { + if (!ascii_buffer_converter(arg, &hexstr)) { goto exit; } return_value = binascii_unhexlify_impl(module, &hexstr); @@ -658,7 +658,7 @@ PyDoc_STRVAR(binascii_a2b_qp__doc__, "Decode a string of qp-encoded data."); #define BINASCII_A2B_QP_METHODDEF \ - {"a2b_qp", (PyCFunction)(void(*)(void))binascii_a2b_qp, METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, + {"a2b_qp", (PyCFunction)(void(*)(void))binascii_a2b_qp, METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, static PyObject * binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header); @@ -668,32 +668,32 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "header", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "a2b_qp", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "a2b_qp", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int header = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!ascii_buffer_converter(args[0], &data)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - header = _PyLong_AsInt(args[1]); - if (header == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!ascii_buffer_converter(args[0], &data)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + header = _PyLong_AsInt(args[1]); + if (header == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = binascii_a2b_qp_impl(module, &data, header); exit: @@ -715,7 +715,7 @@ PyDoc_STRVAR(binascii_b2a_qp__doc__, "are both encoded. When quotetabs is set, space and tabs are encoded."); #define BINASCII_B2A_QP_METHODDEF \ - {"b2a_qp", (PyCFunction)(void(*)(void))binascii_b2a_qp, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, + {"b2a_qp", (PyCFunction)(void(*)(void))binascii_b2a_qp, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, static PyObject * binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, @@ -726,66 +726,66 @@ binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "quotetabs", "istext", "header", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "b2a_qp", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_qp", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int quotetabs = 0; int istext = 1; int header = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("b2a_qp", "argument 'data'", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - quotetabs = _PyLong_AsInt(args[1]); - if (quotetabs == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - istext = _PyLong_AsInt(args[2]); - if (istext == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - header = _PyLong_AsInt(args[3]); - if (header == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_qp", "argument 'data'", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + quotetabs = _PyLong_AsInt(args[1]); + if (quotetabs == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + istext = _PyLong_AsInt(args[2]); + if (istext == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + header = _PyLong_AsInt(args[3]); + if (header == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header); exit: @@ -796,4 +796,4 @@ exit: return return_value; } -/*[clinic end generated code: output=a1e878d3963b615e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a1e878d3963b615e input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/cmathmodule.c.h b/contrib/tools/python3/src/Modules/clinic/cmathmodule.c.h index 4b6653aa21..862598c213 100644 --- a/contrib/tools/python3/src/Modules/clinic/cmathmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/cmathmodule.c.h @@ -21,12 +21,12 @@ cmath_acos(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_acos_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -63,12 +63,12 @@ cmath_acosh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_acosh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -105,12 +105,12 @@ cmath_asin(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_asin_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -147,12 +147,12 @@ cmath_asinh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_asinh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -189,12 +189,12 @@ cmath_atan(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_atan_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -231,12 +231,12 @@ cmath_atanh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_atanh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -273,12 +273,12 @@ cmath_cos(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_cos_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -315,12 +315,12 @@ cmath_cosh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_cosh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -357,12 +357,12 @@ cmath_exp(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_exp_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -399,12 +399,12 @@ cmath_log10(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_log10_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -441,12 +441,12 @@ cmath_sin(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_sin_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -483,12 +483,12 @@ cmath_sinh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_sinh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -525,12 +525,12 @@ cmath_sqrt(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_sqrt_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -567,12 +567,12 @@ cmath_tan(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_tan_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -609,12 +609,12 @@ cmath_tanh(PyObject *module, PyObject *arg) Py_complex z; Py_complex _return_value; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } /* modifications for z */ - errno = 0; + errno = 0; _return_value = cmath_tanh_impl(module, z); if (errno == EDOM) { PyErr_SetString(PyExc_ValueError, "math domain error"); @@ -633,15 +633,15 @@ exit: } PyDoc_STRVAR(cmath_log__doc__, -"log($module, z, base=<unrepresentable>, /)\n" +"log($module, z, base=<unrepresentable>, /)\n" "--\n" "\n" -"log(z[, base]) -> the logarithm of z to the given base.\n" +"log(z[, base]) -> the logarithm of z to the given base.\n" "\n" "If the base not specified, returns the natural logarithm (base e) of z."); #define CMATH_LOG_METHODDEF \ - {"log", (PyCFunction)(void(*)(void))cmath_log, METH_FASTCALL, cmath_log__doc__}, + {"log", (PyCFunction)(void(*)(void))cmath_log, METH_FASTCALL, cmath_log__doc__}, static PyObject * cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj); @@ -653,18 +653,18 @@ cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_complex x; PyObject *y_obj = NULL; - if (!_PyArg_CheckPositional("log", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("log", nargs, 1, 2)) { goto exit; } - x = PyComplex_AsCComplex(args[0]); - if (PyErr_Occurred()) { - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - y_obj = args[1]; -skip_optional: + x = PyComplex_AsCComplex(args[0]); + if (PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + y_obj = args[1]; +skip_optional: return_value = cmath_log_impl(module, x, y_obj); exit: @@ -689,8 +689,8 @@ cmath_phase(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_complex z; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } return_value = cmath_phase_impl(module, z); @@ -719,8 +719,8 @@ cmath_polar(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_complex z; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } return_value = cmath_polar_impl(module, z); @@ -736,7 +736,7 @@ PyDoc_STRVAR(cmath_rect__doc__, "Convert from polar coordinates to rectangular coordinates."); #define CMATH_RECT_METHODDEF \ - {"rect", (PyCFunction)(void(*)(void))cmath_rect, METH_FASTCALL, cmath_rect__doc__}, + {"rect", (PyCFunction)(void(*)(void))cmath_rect, METH_FASTCALL, cmath_rect__doc__}, static PyObject * cmath_rect_impl(PyObject *module, double r, double phi); @@ -748,29 +748,29 @@ cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double r; double phi; - if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_CheckExact(args[0])) { - r = PyFloat_AS_DOUBLE(args[0]); - } - else - { - r = PyFloat_AsDouble(args[0]); - if (r == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - phi = PyFloat_AS_DOUBLE(args[1]); - } - else - { - phi = PyFloat_AsDouble(args[1]); - if (phi == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_CheckExact(args[0])) { + r = PyFloat_AS_DOUBLE(args[0]); + } + else + { + r = PyFloat_AsDouble(args[0]); + if (r == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + phi = PyFloat_AS_DOUBLE(args[1]); + } + else + { + phi = PyFloat_AsDouble(args[1]); + if (phi == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = cmath_rect_impl(module, r, phi); exit: @@ -795,8 +795,8 @@ cmath_isfinite(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_complex z; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } return_value = cmath_isfinite_impl(module, z); @@ -823,8 +823,8 @@ cmath_isnan(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_complex z; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } return_value = cmath_isnan_impl(module, z); @@ -851,8 +851,8 @@ cmath_isinf(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_complex z; - z = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) { + z = PyComplex_AsCComplex(arg); + if (PyErr_Occurred()) { goto exit; } return_value = cmath_isinf_impl(module, z); @@ -883,7 +883,7 @@ PyDoc_STRVAR(cmath_isclose__doc__, "not close to anything, even itself. inf and -inf are only close to themselves."); #define CMATH_ISCLOSE_METHODDEF \ - {"isclose", (PyCFunction)(void(*)(void))cmath_isclose, METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__}, + {"isclose", (PyCFunction)(void(*)(void))cmath_isclose, METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__}, static int cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b, @@ -894,56 +894,56 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; Py_complex a; Py_complex b; double rel_tol = 1e-09; double abs_tol = 0.0; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - a = PyComplex_AsCComplex(args[0]); - if (PyErr_Occurred()) { - goto exit; - } - b = PyComplex_AsCComplex(args[1]); - if (PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (PyFloat_CheckExact(args[2])) { - rel_tol = PyFloat_AS_DOUBLE(args[2]); - } - else - { - rel_tol = PyFloat_AsDouble(args[2]); - if (rel_tol == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (PyFloat_CheckExact(args[3])) { - abs_tol = PyFloat_AS_DOUBLE(args[3]); - } - else - { - abs_tol = PyFloat_AsDouble(args[3]); - if (abs_tol == -1.0 && PyErr_Occurred()) { - goto exit; - } - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = PyComplex_AsCComplex(args[0]); + if (PyErr_Occurred()) { + goto exit; + } + b = PyComplex_AsCComplex(args[1]); + if (PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (PyFloat_CheckExact(args[2])) { + rel_tol = PyFloat_AS_DOUBLE(args[2]); + } + else + { + rel_tol = PyFloat_AsDouble(args[2]); + if (rel_tol == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_CheckExact(args[3])) { + abs_tol = PyFloat_AS_DOUBLE(args[3]); + } + else + { + abs_tol = PyFloat_AsDouble(args[3]); + if (abs_tol == -1.0 && PyErr_Occurred()) { + goto exit; + } + } +skip_optional_kwonly: _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -953,4 +953,4 @@ skip_optional_kwonly: exit: return return_value; } -/*[clinic end generated code: output=353347db2e808e0d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=353347db2e808e0d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/fcntlmodule.c.h b/contrib/tools/python3/src/Modules/clinic/fcntlmodule.c.h index 024a44cfbf..c07632afd0 100644 --- a/contrib/tools/python3/src/Modules/clinic/fcntlmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/fcntlmodule.c.h @@ -19,7 +19,7 @@ PyDoc_STRVAR(fcntl_fcntl__doc__, "corresponding to the return value of the fcntl call in the C code."); #define FCNTL_FCNTL_METHODDEF \ - {"fcntl", (PyCFunction)(void(*)(void))fcntl_fcntl, METH_FASTCALL, fcntl_fcntl__doc__}, + {"fcntl", (PyCFunction)(void(*)(void))fcntl_fcntl, METH_FASTCALL, fcntl_fcntl__doc__}, static PyObject * fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg); @@ -32,26 +32,26 @@ fcntl_fcntl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int code; PyObject *arg = NULL; - if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) { + if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) { goto exit; } - if (!conv_descriptor(args[0], &fd)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = _PyLong_AsInt(args[1]); - if (code == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - arg = args[2]; -skip_optional: + if (!conv_descriptor(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + code = _PyLong_AsInt(args[1]); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + arg = args[2]; +skip_optional: return_value = fcntl_fcntl_impl(module, fd, code, arg); exit: @@ -92,7 +92,7 @@ PyDoc_STRVAR(fcntl_ioctl__doc__, "code."); #define FCNTL_IOCTL_METHODDEF \ - {"ioctl", (PyCFunction)(void(*)(void))fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__}, + {"ioctl", (PyCFunction)(void(*)(void))fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__}, static PyObject * fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code, @@ -107,33 +107,33 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *ob_arg = NULL; int mutate_arg = 1; - if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) { - goto exit; - } - if (!conv_descriptor(args[0], &fd)) { + if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) { goto exit; } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (code == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - ob_arg = args[2]; - if (nargs < 4) { - goto skip_optional; - } - mutate_arg = PyObject_IsTrue(args[3]); - if (mutate_arg < 0) { - goto exit; - } -skip_optional: + if (!conv_descriptor(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (code == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + ob_arg = args[2]; + if (nargs < 4) { + goto skip_optional; + } + mutate_arg = PyObject_IsTrue(args[3]); + if (mutate_arg < 0) { + goto exit; + } +skip_optional: return_value = fcntl_ioctl_impl(module, fd, code, ob_arg, mutate_arg); exit: @@ -150,7 +150,7 @@ PyDoc_STRVAR(fcntl_flock__doc__, "function is emulated using fcntl())."); #define FCNTL_FLOCK_METHODDEF \ - {"flock", (PyCFunction)(void(*)(void))fcntl_flock, METH_FASTCALL, fcntl_flock__doc__}, + {"flock", (PyCFunction)(void(*)(void))fcntl_flock, METH_FASTCALL, fcntl_flock__doc__}, static PyObject * fcntl_flock_impl(PyObject *module, int fd, int code); @@ -162,21 +162,21 @@ fcntl_flock(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int fd; int code; - if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) { - goto exit; - } - if (!conv_descriptor(args[0], &fd)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = _PyLong_AsInt(args[1]); - if (code == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) { goto exit; } + if (!conv_descriptor(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + code = _PyLong_AsInt(args[1]); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } return_value = fcntl_flock_impl(module, fd, code); exit: @@ -211,7 +211,7 @@ PyDoc_STRVAR(fcntl_lockf__doc__, " 2 - relative to the end of the file (SEEK_END)"); #define FCNTL_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)(void(*)(void))fcntl_lockf, METH_FASTCALL, fcntl_lockf__doc__}, + {"lockf", (PyCFunction)(void(*)(void))fcntl_lockf, METH_FASTCALL, fcntl_lockf__doc__}, static PyObject * fcntl_lockf_impl(PyObject *module, int fd, int code, PyObject *lenobj, @@ -227,45 +227,45 @@ fcntl_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *startobj = NULL; int whence = 0; - if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) { - goto exit; - } - if (!conv_descriptor(args[0], &fd)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = _PyLong_AsInt(args[1]); - if (code == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - lenobj = args[2]; - if (nargs < 4) { - goto skip_optional; - } - startobj = args[3]; - if (nargs < 5) { - goto skip_optional; - } - if (PyFloat_Check(args[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[4]); - if (whence == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) { goto exit; } -skip_optional: + if (!conv_descriptor(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + code = _PyLong_AsInt(args[1]); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + lenobj = args[2]; + if (nargs < 4) { + goto skip_optional; + } + startobj = args[3]; + if (nargs < 5) { + goto skip_optional; + } + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + whence = _PyLong_AsInt(args[4]); + if (whence == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = fcntl_lockf_impl(module, fd, code, lenobj, startobj, whence); exit: return return_value; } -/*[clinic end generated code: output=e912d25e28362c52 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e912d25e28362c52 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/gcmodule.c.h b/contrib/tools/python3/src/Modules/clinic/gcmodule.c.h index 72795c66bf..c4301d24e3 100644 --- a/contrib/tools/python3/src/Modules/clinic/gcmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/gcmodule.c.h @@ -79,7 +79,7 @@ PyDoc_STRVAR(gc_collect__doc__, "The number of unreachable objects is returned."); #define GC_COLLECT_METHODDEF \ - {"collect", (PyCFunction)(void(*)(void))gc_collect, METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__}, + {"collect", (PyCFunction)(void(*)(void))gc_collect, METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__}, static Py_ssize_t gc_collect_impl(PyObject *module, int generation); @@ -89,29 +89,29 @@ gc_collect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"generation", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "collect", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "collect", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int generation = NUM_GENERATIONS - 1; Py_ssize_t _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - generation = _PyLong_AsInt(args[0]); - if (generation == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + generation = _PyLong_AsInt(args[0]); + if (generation == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: _return_value = gc_collect_impl(module, generation); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -151,15 +151,15 @@ gc_set_debug(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int flags; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(arg); - if (flags == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + flags = _PyLong_AsInt(arg); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } return_value = gc_set_debug_impl(module, flags); exit: @@ -231,48 +231,48 @@ gc_get_count(PyObject *module, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(gc_get_objects__doc__, -"get_objects($module, /, generation=None)\n" +"get_objects($module, /, generation=None)\n" "--\n" "\n" -"Return a list of objects tracked by the collector (excluding the list returned).\n" -"\n" -" generation\n" -" Generation to extract the objects from.\n" -"\n" -"If generation is not None, return only the objects tracked by the collector\n" -"that are in that generation."); +"Return a list of objects tracked by the collector (excluding the list returned).\n" +"\n" +" generation\n" +" Generation to extract the objects from.\n" +"\n" +"If generation is not None, return only the objects tracked by the collector\n" +"that are in that generation."); #define GC_GET_OBJECTS_METHODDEF \ - {"get_objects", (PyCFunction)(void(*)(void))gc_get_objects, METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, + {"get_objects", (PyCFunction)(void(*)(void))gc_get_objects, METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, static PyObject * -gc_get_objects_impl(PyObject *module, Py_ssize_t generation); +gc_get_objects_impl(PyObject *module, Py_ssize_t generation); static PyObject * -gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = {"generation", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "get_objects", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - Py_ssize_t generation = -1; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &generation)) { - goto exit; - } -skip_optional_pos: - return_value = gc_get_objects_impl(module, generation); - -exit: - return return_value; + PyObject *return_value = NULL; + static const char * const _keywords[] = {"generation", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "get_objects", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + Py_ssize_t generation = -1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &generation)) { + goto exit; + } +skip_optional_pos: + return_value = gc_get_objects_impl(module, generation); + +exit: + return return_value; } PyDoc_STRVAR(gc_get_stats__doc__, @@ -304,15 +304,15 @@ PyDoc_STRVAR(gc_is_tracked__doc__, #define GC_IS_TRACKED_METHODDEF \ {"is_tracked", (PyCFunction)gc_is_tracked, METH_O, gc_is_tracked__doc__}, -PyDoc_STRVAR(gc_is_finalized__doc__, -"is_finalized($module, obj, /)\n" -"--\n" -"\n" -"Returns true if the object has been already finalized by the GC."); - -#define GC_IS_FINALIZED_METHODDEF \ - {"is_finalized", (PyCFunction)gc_is_finalized, METH_O, gc_is_finalized__doc__}, - +PyDoc_STRVAR(gc_is_finalized__doc__, +"is_finalized($module, obj, /)\n" +"--\n" +"\n" +"Returns true if the object has been already finalized by the GC."); + +#define GC_IS_FINALIZED_METHODDEF \ + {"is_finalized", (PyCFunction)gc_is_finalized, METH_O, gc_is_finalized__doc__}, + PyDoc_STRVAR(gc_freeze__doc__, "freeze($module, /)\n" "--\n" @@ -382,4 +382,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=bd6a8056989e2e69 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bd6a8056989e2e69 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/grpmodule.c.h b/contrib/tools/python3/src/Modules/clinic/grpmodule.c.h index 2e2690ad8d..dd13197f03 100644 --- a/contrib/tools/python3/src/Modules/clinic/grpmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/grpmodule.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(grp_getgrgid__doc__, "If id is not valid, raise KeyError."); #define GRP_GETGRGID_METHODDEF \ - {"getgrgid", (PyCFunction)(void(*)(void))grp_getgrgid, METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__}, + {"getgrgid", (PyCFunction)(void(*)(void))grp_getgrgid, METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__}, static PyObject * grp_getgrgid_impl(PyObject *module, PyObject *id); @@ -21,15 +21,15 @@ grp_getgrgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"id", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "getgrgid", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "getgrgid", 0}; + PyObject *argsbuf[1]; PyObject *id; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - id = args[0]; + id = args[0]; return_value = grp_getgrgid_impl(module, id); exit: @@ -45,7 +45,7 @@ PyDoc_STRVAR(grp_getgrnam__doc__, "If name is not valid, raise KeyError."); #define GRP_GETGRNAM_METHODDEF \ - {"getgrnam", (PyCFunction)(void(*)(void))grp_getgrnam, METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__}, + {"getgrnam", (PyCFunction)(void(*)(void))grp_getgrnam, METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__}, static PyObject * grp_getgrnam_impl(PyObject *module, PyObject *name); @@ -55,22 +55,22 @@ grp_getgrnam(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "getgrnam", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "getgrnam", 0}; + PyObject *argsbuf[1]; PyObject *name; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("getgrnam", "argument 'name'", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - name = args[0]; + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("getgrnam", "argument 'name'", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + name = args[0]; return_value = grp_getgrnam_impl(module, name); exit: @@ -97,4 +97,4 @@ grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored)) { return grp_getgrall_impl(module); } -/*[clinic end generated code: output=9b3f26779e4e1a52 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9b3f26779e4e1a52 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/itertoolsmodule.c.h b/contrib/tools/python3/src/Modules/clinic/itertoolsmodule.c.h index 20594b0fed..7a31116dd7 100644 --- a/contrib/tools/python3/src/Modules/clinic/itertoolsmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/itertoolsmodule.c.h @@ -1,645 +1,645 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(itertools_groupby__doc__, -"groupby(iterable, key=None)\n" -"--\n" -"\n" -"make an iterator that returns consecutive keys and groups from the iterable\n" -"\n" -" iterable\n" -" Elements to divide into groups according to the key function.\n" -" key\n" -" A function for computing the group category for each element.\n" -" If the key function is not specified or is None, the element itself\n" -" is used for grouping."); - -static PyObject * -itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc); - -static PyObject * -itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"iterable", "key", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "groupby", 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) - 1; - PyObject *it; - PyObject *keyfunc = Py_None; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - it = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - keyfunc = fastargs[1]; -skip_optional_pos: - return_value = itertools_groupby_impl(type, it, keyfunc); - -exit: - return return_value; -} - -static PyObject * -itertools__grouper_impl(PyTypeObject *type, PyObject *parent, - PyObject *tgtkey); - -static PyObject * -itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *parent; - PyObject *tgtkey; - - if ((type == &_grouper_type) && - !_PyArg_NoKeywords("_grouper", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), &groupby_type)) { - _PyArg_BadArgument("_grouper", "argument 1", (&groupby_type)->tp_name, PyTuple_GET_ITEM(args, 0)); - goto exit; - } - parent = PyTuple_GET_ITEM(args, 0); - tgtkey = PyTuple_GET_ITEM(args, 1); - return_value = itertools__grouper_impl(type, parent, tgtkey); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_teedataobject__doc__, -"teedataobject(iterable, values, next, /)\n" -"--\n" -"\n" -"Data container common to multiple tee objects."); - -static PyObject * -itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, - PyObject *values, PyObject *next); - -static PyObject * -itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *it; - PyObject *values; - PyObject *next; - - if ((type == &teedataobject_type) && - !_PyArg_NoKeywords("teedataobject", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) { - goto exit; - } - it = PyTuple_GET_ITEM(args, 0); - if (!PyList_Check(PyTuple_GET_ITEM(args, 1))) { - _PyArg_BadArgument("teedataobject", "argument 2", "list", PyTuple_GET_ITEM(args, 1)); - goto exit; - } - values = PyTuple_GET_ITEM(args, 1); - next = PyTuple_GET_ITEM(args, 2); - return_value = itertools_teedataobject_impl(type, it, values, next); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools__tee__doc__, -"_tee(iterable, /)\n" -"--\n" -"\n" -"Iterator wrapped to make it copyable."); - -static PyObject * -itertools__tee_impl(PyTypeObject *type, PyObject *iterable); - -static PyObject * -itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *iterable; - - if ((type == &tee_type) && - !_PyArg_NoKeywords("_tee", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("_tee", PyTuple_GET_SIZE(args), 1, 1)) { - goto exit; - } - iterable = PyTuple_GET_ITEM(args, 0); - return_value = itertools__tee_impl(type, iterable); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_tee__doc__, -"tee($module, iterable, n=2, /)\n" -"--\n" -"\n" -"Returns a tuple of n independent iterators."); - -#define ITERTOOLS_TEE_METHODDEF \ - {"tee", (PyCFunction)(void(*)(void))itertools_tee, METH_FASTCALL, itertools_tee__doc__}, - -static PyObject * -itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n); - -static PyObject * -itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *iterable; - Py_ssize_t n = 2; - - if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) { - goto exit; - } - iterable = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - n = ival; - } -skip_optional: - return_value = itertools_tee_impl(module, iterable, n); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_cycle__doc__, -"cycle(iterable, /)\n" -"--\n" -"\n" -"Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."); - -static PyObject * -itertools_cycle_impl(PyTypeObject *type, PyObject *iterable); - -static PyObject * -itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *iterable; - - if ((type == &cycle_type) && - !_PyArg_NoKeywords("cycle", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("cycle", PyTuple_GET_SIZE(args), 1, 1)) { - goto exit; - } - iterable = PyTuple_GET_ITEM(args, 0); - return_value = itertools_cycle_impl(type, iterable); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_dropwhile__doc__, -"dropwhile(predicate, iterable, /)\n" -"--\n" -"\n" -"Drop items from the iterable while predicate(item) is true.\n" -"\n" -"Afterwards, return every element until the iterable is exhausted."); - -static PyObject * -itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); - -static PyObject * -itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *func; - PyObject *seq; - - if ((type == &dropwhile_type) && - !_PyArg_NoKeywords("dropwhile", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("dropwhile", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - func = PyTuple_GET_ITEM(args, 0); - seq = PyTuple_GET_ITEM(args, 1); - return_value = itertools_dropwhile_impl(type, func, seq); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_takewhile__doc__, -"takewhile(predicate, iterable, /)\n" -"--\n" -"\n" -"Return successive entries from an iterable as long as the predicate evaluates to true for each entry."); - -static PyObject * -itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); - -static PyObject * -itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *func; - PyObject *seq; - - if ((type == &takewhile_type) && - !_PyArg_NoKeywords("takewhile", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("takewhile", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - func = PyTuple_GET_ITEM(args, 0); - seq = PyTuple_GET_ITEM(args, 1); - return_value = itertools_takewhile_impl(type, func, seq); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_starmap__doc__, -"starmap(function, iterable, /)\n" -"--\n" -"\n" -"Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."); - -static PyObject * -itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq); - -static PyObject * -itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *func; - PyObject *seq; - - if ((type == &starmap_type) && - !_PyArg_NoKeywords("starmap", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("starmap", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - func = PyTuple_GET_ITEM(args, 0); - seq = PyTuple_GET_ITEM(args, 1); - return_value = itertools_starmap_impl(type, func, seq); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_chain_from_iterable__doc__, -"from_iterable($type, iterable, /)\n" -"--\n" -"\n" -"Alternative chain() constructor taking a single iterable argument that evaluates lazily."); - -#define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \ - {"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__}, - -PyDoc_STRVAR(itertools_combinations__doc__, -"combinations(iterable, r)\n" -"--\n" -"\n" -"Return successive r-length combinations of elements in the iterable.\n" -"\n" -"combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"); - -static PyObject * -itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, - Py_ssize_t r); - -static PyObject * -itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "combinations", 0}; - PyObject *argsbuf[2]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - PyObject *iterable; - Py_ssize_t r; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - iterable = fastargs[0]; - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(fastargs[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - r = ival; - } - return_value = itertools_combinations_impl(type, iterable, r); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_combinations_with_replacement__doc__, -"combinations_with_replacement(iterable, r)\n" -"--\n" -"\n" -"Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.\n" -"\n" -"combinations_with_replacement(\'ABC\', 2) --> AA AB AC BB BC CC\""); - -static PyObject * -itertools_combinations_with_replacement_impl(PyTypeObject *type, - PyObject *iterable, - Py_ssize_t r); - -static PyObject * -itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "combinations_with_replacement", 0}; - PyObject *argsbuf[2]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - PyObject *iterable; - Py_ssize_t r; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - iterable = fastargs[0]; - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(fastargs[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - r = ival; - } - return_value = itertools_combinations_with_replacement_impl(type, iterable, r); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_permutations__doc__, -"permutations(iterable, r=None)\n" -"--\n" -"\n" -"Return successive r-length permutations of elements in the iterable.\n" -"\n" -"permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"); - -static PyObject * -itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, - PyObject *robj); - -static PyObject * -itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "permutations", 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) - 1; - PyObject *iterable; - PyObject *robj = Py_None; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - iterable = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - robj = fastargs[1]; -skip_optional_pos: - return_value = itertools_permutations_impl(type, iterable, robj); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_accumulate__doc__, -"accumulate(iterable, func=None, *, initial=None)\n" -"--\n" -"\n" -"Return series of accumulated sums (or other binary function results)."); - -static PyObject * -itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, - PyObject *binop, PyObject *initial); - -static PyObject * -itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"iterable", "func", "initial", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "accumulate", 0}; - PyObject *argsbuf[3]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - PyObject *iterable; - PyObject *binop = Py_None; - PyObject *initial = Py_None; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - iterable = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[1]) { - binop = fastargs[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - initial = fastargs[2]; -skip_optional_kwonly: - return_value = itertools_accumulate_impl(type, iterable, binop, initial); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_compress__doc__, -"compress(data, selectors)\n" -"--\n" -"\n" -"Return data elements corresponding to true selector elements.\n" -"\n" -"Forms a shorter iterator from selected data elements using the selectors to\n" -"choose the data elements."); - -static PyObject * -itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2); - -static PyObject * -itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"data", "selectors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; - PyObject *argsbuf[2]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - PyObject *seq1; - PyObject *seq2; - - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); - if (!fastargs) { - goto exit; - } - seq1 = fastargs[0]; - seq2 = fastargs[1]; - return_value = itertools_compress_impl(type, seq1, seq2); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_filterfalse__doc__, -"filterfalse(function, iterable, /)\n" -"--\n" -"\n" -"Return those items of iterable for which function(item) is false.\n" -"\n" -"If function is None, return the items that are false."); - -static PyObject * -itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq); - -static PyObject * -itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *func; - PyObject *seq; - - if ((type == &filterfalse_type) && - !_PyArg_NoKeywords("filterfalse", kwargs)) { - goto exit; - } - if (!_PyArg_CheckPositional("filterfalse", PyTuple_GET_SIZE(args), 2, 2)) { - goto exit; - } - func = PyTuple_GET_ITEM(args, 0); - seq = PyTuple_GET_ITEM(args, 1); - return_value = itertools_filterfalse_impl(type, func, seq); - -exit: - return return_value; -} - -PyDoc_STRVAR(itertools_count__doc__, -"count(start=0, step=1)\n" -"--\n" -"\n" -"Return a count object whose .__next__() method returns consecutive values.\n" -"\n" -"Equivalent to:\n" -" def count(firstval=0, step=1):\n" -" x = firstval\n" -" while 1:\n" -" yield x\n" -" x += step"); - -static PyObject * -itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, - PyObject *long_step); - -static PyObject * -itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"start", "step", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "count", 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; - PyObject *long_cnt = NULL; - PyObject *long_step = NULL; - - 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]) { - long_cnt = fastargs[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - long_step = fastargs[1]; -skip_optional_pos: - return_value = itertools_count_impl(type, long_cnt, long_step); - -exit: - return return_value; -} -/*[clinic end generated code: output=392c9706e79f6710 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(itertools_groupby__doc__, +"groupby(iterable, key=None)\n" +"--\n" +"\n" +"make an iterator that returns consecutive keys and groups from the iterable\n" +"\n" +" iterable\n" +" Elements to divide into groups according to the key function.\n" +" key\n" +" A function for computing the group category for each element.\n" +" If the key function is not specified or is None, the element itself\n" +" is used for grouping."); + +static PyObject * +itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc); + +static PyObject * +itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "key", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "groupby", 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) - 1; + PyObject *it; + PyObject *keyfunc = Py_None; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + it = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + keyfunc = fastargs[1]; +skip_optional_pos: + return_value = itertools_groupby_impl(type, it, keyfunc); + +exit: + return return_value; +} + +static PyObject * +itertools__grouper_impl(PyTypeObject *type, PyObject *parent, + PyObject *tgtkey); + +static PyObject * +itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *parent; + PyObject *tgtkey; + + if ((type == &_grouper_type) && + !_PyArg_NoKeywords("_grouper", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), &groupby_type)) { + _PyArg_BadArgument("_grouper", "argument 1", (&groupby_type)->tp_name, PyTuple_GET_ITEM(args, 0)); + goto exit; + } + parent = PyTuple_GET_ITEM(args, 0); + tgtkey = PyTuple_GET_ITEM(args, 1); + return_value = itertools__grouper_impl(type, parent, tgtkey); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_teedataobject__doc__, +"teedataobject(iterable, values, next, /)\n" +"--\n" +"\n" +"Data container common to multiple tee objects."); + +static PyObject * +itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, + PyObject *values, PyObject *next); + +static PyObject * +itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *it; + PyObject *values; + PyObject *next; + + if ((type == &teedataobject_type) && + !_PyArg_NoKeywords("teedataobject", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) { + goto exit; + } + it = PyTuple_GET_ITEM(args, 0); + if (!PyList_Check(PyTuple_GET_ITEM(args, 1))) { + _PyArg_BadArgument("teedataobject", "argument 2", "list", PyTuple_GET_ITEM(args, 1)); + goto exit; + } + values = PyTuple_GET_ITEM(args, 1); + next = PyTuple_GET_ITEM(args, 2); + return_value = itertools_teedataobject_impl(type, it, values, next); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools__tee__doc__, +"_tee(iterable, /)\n" +"--\n" +"\n" +"Iterator wrapped to make it copyable."); + +static PyObject * +itertools__tee_impl(PyTypeObject *type, PyObject *iterable); + +static PyObject * +itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *iterable; + + if ((type == &tee_type) && + !_PyArg_NoKeywords("_tee", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("_tee", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + iterable = PyTuple_GET_ITEM(args, 0); + return_value = itertools__tee_impl(type, iterable); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_tee__doc__, +"tee($module, iterable, n=2, /)\n" +"--\n" +"\n" +"Returns a tuple of n independent iterators."); + +#define ITERTOOLS_TEE_METHODDEF \ + {"tee", (PyCFunction)(void(*)(void))itertools_tee, METH_FASTCALL, itertools_tee__doc__}, + +static PyObject * +itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n); + +static PyObject * +itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *iterable; + Py_ssize_t n = 2; + + if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) { + goto exit; + } + iterable = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + n = ival; + } +skip_optional: + return_value = itertools_tee_impl(module, iterable, n); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_cycle__doc__, +"cycle(iterable, /)\n" +"--\n" +"\n" +"Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."); + +static PyObject * +itertools_cycle_impl(PyTypeObject *type, PyObject *iterable); + +static PyObject * +itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *iterable; + + if ((type == &cycle_type) && + !_PyArg_NoKeywords("cycle", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("cycle", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + iterable = PyTuple_GET_ITEM(args, 0); + return_value = itertools_cycle_impl(type, iterable); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_dropwhile__doc__, +"dropwhile(predicate, iterable, /)\n" +"--\n" +"\n" +"Drop items from the iterable while predicate(item) is true.\n" +"\n" +"Afterwards, return every element until the iterable is exhausted."); + +static PyObject * +itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); + +static PyObject * +itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *seq; + + if ((type == &dropwhile_type) && + !_PyArg_NoKeywords("dropwhile", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("dropwhile", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); + return_value = itertools_dropwhile_impl(type, func, seq); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_takewhile__doc__, +"takewhile(predicate, iterable, /)\n" +"--\n" +"\n" +"Return successive entries from an iterable as long as the predicate evaluates to true for each entry."); + +static PyObject * +itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); + +static PyObject * +itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *seq; + + if ((type == &takewhile_type) && + !_PyArg_NoKeywords("takewhile", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("takewhile", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); + return_value = itertools_takewhile_impl(type, func, seq); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_starmap__doc__, +"starmap(function, iterable, /)\n" +"--\n" +"\n" +"Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."); + +static PyObject * +itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq); + +static PyObject * +itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *seq; + + if ((type == &starmap_type) && + !_PyArg_NoKeywords("starmap", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("starmap", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); + return_value = itertools_starmap_impl(type, func, seq); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_chain_from_iterable__doc__, +"from_iterable($type, iterable, /)\n" +"--\n" +"\n" +"Alternative chain() constructor taking a single iterable argument that evaluates lazily."); + +#define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \ + {"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__}, + +PyDoc_STRVAR(itertools_combinations__doc__, +"combinations(iterable, r)\n" +"--\n" +"\n" +"Return successive r-length combinations of elements in the iterable.\n" +"\n" +"combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"); + +static PyObject * +itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, + Py_ssize_t r); + +static PyObject * +itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "r", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "combinations", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + PyObject *iterable; + Py_ssize_t r; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + } + return_value = itertools_combinations_impl(type, iterable, r); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_combinations_with_replacement__doc__, +"combinations_with_replacement(iterable, r)\n" +"--\n" +"\n" +"Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.\n" +"\n" +"combinations_with_replacement(\'ABC\', 2) --> AA AB AC BB BC CC\""); + +static PyObject * +itertools_combinations_with_replacement_impl(PyTypeObject *type, + PyObject *iterable, + Py_ssize_t r); + +static PyObject * +itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "r", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "combinations_with_replacement", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + PyObject *iterable; + Py_ssize_t r; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + } + return_value = itertools_combinations_with_replacement_impl(type, iterable, r); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_permutations__doc__, +"permutations(iterable, r=None)\n" +"--\n" +"\n" +"Return successive r-length permutations of elements in the iterable.\n" +"\n" +"permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"); + +static PyObject * +itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, + PyObject *robj); + +static PyObject * +itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "r", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "permutations", 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) - 1; + PyObject *iterable; + PyObject *robj = Py_None; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + robj = fastargs[1]; +skip_optional_pos: + return_value = itertools_permutations_impl(type, iterable, robj); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_accumulate__doc__, +"accumulate(iterable, func=None, *, initial=None)\n" +"--\n" +"\n" +"Return series of accumulated sums (or other binary function results)."); + +static PyObject * +itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, + PyObject *binop, PyObject *initial); + +static PyObject * +itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "func", "initial", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "accumulate", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + PyObject *iterable; + PyObject *binop = Py_None; + PyObject *initial = Py_None; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + binop = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + initial = fastargs[2]; +skip_optional_kwonly: + return_value = itertools_accumulate_impl(type, iterable, binop, initial); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_compress__doc__, +"compress(data, selectors)\n" +"--\n" +"\n" +"Return data elements corresponding to true selector elements.\n" +"\n" +"Forms a shorter iterator from selected data elements using the selectors to\n" +"choose the data elements."); + +static PyObject * +itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2); + +static PyObject * +itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"data", "selectors", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + PyObject *seq1; + PyObject *seq2; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + seq1 = fastargs[0]; + seq2 = fastargs[1]; + return_value = itertools_compress_impl(type, seq1, seq2); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_filterfalse__doc__, +"filterfalse(function, iterable, /)\n" +"--\n" +"\n" +"Return those items of iterable for which function(item) is false.\n" +"\n" +"If function is None, return the items that are false."); + +static PyObject * +itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq); + +static PyObject * +itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *seq; + + if ((type == &filterfalse_type) && + !_PyArg_NoKeywords("filterfalse", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("filterfalse", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); + return_value = itertools_filterfalse_impl(type, func, seq); + +exit: + return return_value; +} + +PyDoc_STRVAR(itertools_count__doc__, +"count(start=0, step=1)\n" +"--\n" +"\n" +"Return a count object whose .__next__() method returns consecutive values.\n" +"\n" +"Equivalent to:\n" +" def count(firstval=0, step=1):\n" +" x = firstval\n" +" while 1:\n" +" yield x\n" +" x += step"); + +static PyObject * +itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, + PyObject *long_step); + +static PyObject * +itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"start", "step", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "count", 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; + PyObject *long_cnt = NULL; + PyObject *long_step = NULL; + + 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]) { + long_cnt = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + long_step = fastargs[1]; +skip_optional_pos: + return_value = itertools_count_impl(type, long_cnt, long_step); + +exit: + return return_value; +} +/*[clinic end generated code: output=392c9706e79f6710 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/mathmodule.c.h b/contrib/tools/python3/src/Modules/clinic/mathmodule.c.h index 65f3dd4f52..52551a0a79 100644 --- a/contrib/tools/python3/src/Modules/clinic/mathmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/mathmodule.c.h @@ -35,15 +35,15 @@ PyDoc_STRVAR(math_fsum__doc__, #define MATH_FSUM_METHODDEF \ {"fsum", (PyCFunction)math_fsum, METH_O, math_fsum__doc__}, -PyDoc_STRVAR(math_isqrt__doc__, -"isqrt($module, n, /)\n" -"--\n" -"\n" -"Return the integer part of the square root of the input."); - -#define MATH_ISQRT_METHODDEF \ - {"isqrt", (PyCFunction)math_isqrt, METH_O, math_isqrt__doc__}, - +PyDoc_STRVAR(math_isqrt__doc__, +"isqrt($module, n, /)\n" +"--\n" +"\n" +"Return the integer part of the square root of the input."); + +#define MATH_ISQRT_METHODDEF \ + {"isqrt", (PyCFunction)math_isqrt, METH_O, math_isqrt__doc__}, + PyDoc_STRVAR(math_factorial__doc__, "factorial($module, x, /)\n" "--\n" @@ -87,16 +87,16 @@ math_frexp(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_frexp_impl(module, x); exit: @@ -112,7 +112,7 @@ PyDoc_STRVAR(math_ldexp__doc__, "This is essentially the inverse of frexp()."); #define MATH_LDEXP_METHODDEF \ - {"ldexp", (PyCFunction)(void(*)(void))math_ldexp, METH_FASTCALL, math_ldexp__doc__}, + {"ldexp", (PyCFunction)(void(*)(void))math_ldexp, METH_FASTCALL, math_ldexp__doc__}, static PyObject * math_ldexp_impl(PyObject *module, double x, PyObject *i); @@ -124,20 +124,20 @@ math_ldexp(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double x; PyObject *i; - if (!_PyArg_CheckPositional("ldexp", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("ldexp", nargs, 2, 2)) { goto exit; } - if (PyFloat_CheckExact(args[0])) { - x = PyFloat_AS_DOUBLE(args[0]); - } - else - { - x = PyFloat_AsDouble(args[0]); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - i = args[1]; + if (PyFloat_CheckExact(args[0])) { + x = PyFloat_AS_DOUBLE(args[0]); + } + else + { + x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + i = args[1]; return_value = math_ldexp_impl(module, x, i); exit: @@ -164,16 +164,16 @@ math_modf(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_modf_impl(module, x); exit: @@ -250,7 +250,7 @@ PyDoc_STRVAR(math_fmod__doc__, "x % y may differ."); #define MATH_FMOD_METHODDEF \ - {"fmod", (PyCFunction)(void(*)(void))math_fmod, METH_FASTCALL, math_fmod__doc__}, + {"fmod", (PyCFunction)(void(*)(void))math_fmod, METH_FASTCALL, math_fmod__doc__}, static PyObject * math_fmod_impl(PyObject *module, double x, double y); @@ -262,66 +262,66 @@ math_fmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double x; double y; - if (!_PyArg_CheckPositional("fmod", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("fmod", nargs, 2, 2)) { goto exit; } - if (PyFloat_CheckExact(args[0])) { - x = PyFloat_AS_DOUBLE(args[0]); - } - else - { - x = PyFloat_AsDouble(args[0]); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - y = PyFloat_AS_DOUBLE(args[1]); - } - else - { - y = PyFloat_AsDouble(args[1]); - if (y == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (PyFloat_CheckExact(args[0])) { + x = PyFloat_AS_DOUBLE(args[0]); + } + else + { + x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + y = PyFloat_AS_DOUBLE(args[1]); + } + else + { + y = PyFloat_AsDouble(args[1]); + if (y == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_fmod_impl(module, x, y); exit: return return_value; } -PyDoc_STRVAR(math_dist__doc__, -"dist($module, p, q, /)\n" +PyDoc_STRVAR(math_dist__doc__, +"dist($module, p, q, /)\n" "--\n" "\n" -"Return the Euclidean distance between two points p and q.\n" -"\n" -"The points should be specified as sequences (or iterables) of\n" -"coordinates. Both inputs must have the same dimension.\n" -"\n" -"Roughly equivalent to:\n" -" sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))"); +"Return the Euclidean distance between two points p and q.\n" +"\n" +"The points should be specified as sequences (or iterables) of\n" +"coordinates. Both inputs must have the same dimension.\n" +"\n" +"Roughly equivalent to:\n" +" sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))"); -#define MATH_DIST_METHODDEF \ - {"dist", (PyCFunction)(void(*)(void))math_dist, METH_FASTCALL, math_dist__doc__}, +#define MATH_DIST_METHODDEF \ + {"dist", (PyCFunction)(void(*)(void))math_dist, METH_FASTCALL, math_dist__doc__}, static PyObject * -math_dist_impl(PyObject *module, PyObject *p, PyObject *q); +math_dist_impl(PyObject *module, PyObject *p, PyObject *q); static PyObject * -math_dist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +math_dist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *p; - PyObject *q; + PyObject *p; + PyObject *q; - if (!_PyArg_CheckPositional("dist", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("dist", nargs, 2, 2)) { goto exit; } - p = args[0]; - q = args[1]; - return_value = math_dist_impl(module, p, q); + p = args[0]; + q = args[1]; + return_value = math_dist_impl(module, p, q); exit: return return_value; @@ -334,7 +334,7 @@ PyDoc_STRVAR(math_pow__doc__, "Return x**y (x to the power of y)."); #define MATH_POW_METHODDEF \ - {"pow", (PyCFunction)(void(*)(void))math_pow, METH_FASTCALL, math_pow__doc__}, + {"pow", (PyCFunction)(void(*)(void))math_pow, METH_FASTCALL, math_pow__doc__}, static PyObject * math_pow_impl(PyObject *module, double x, double y); @@ -346,29 +346,29 @@ math_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs) double x; double y; - if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) { goto exit; } - if (PyFloat_CheckExact(args[0])) { - x = PyFloat_AS_DOUBLE(args[0]); - } - else - { - x = PyFloat_AsDouble(args[0]); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - y = PyFloat_AS_DOUBLE(args[1]); - } - else - { - y = PyFloat_AsDouble(args[1]); - if (y == -1.0 && PyErr_Occurred()) { - goto exit; - } - } + if (PyFloat_CheckExact(args[0])) { + x = PyFloat_AS_DOUBLE(args[0]); + } + else + { + x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + y = PyFloat_AS_DOUBLE(args[1]); + } + else + { + y = PyFloat_AsDouble(args[1]); + if (y == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_pow_impl(module, x, y); exit: @@ -393,16 +393,16 @@ math_degrees(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_degrees_impl(module, x); exit: @@ -427,16 +427,16 @@ math_radians(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_radians_impl(module, x); exit: @@ -461,16 +461,16 @@ math_isfinite(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_isfinite_impl(module, x); exit: @@ -495,16 +495,16 @@ math_isnan(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_isnan_impl(module, x); exit: @@ -529,16 +529,16 @@ math_isinf(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double x; - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } return_value = math_isinf_impl(module, x); exit: @@ -568,7 +568,7 @@ PyDoc_STRVAR(math_isclose__doc__, "only close to themselves."); #define MATH_ISCLOSE_METHODDEF \ - {"isclose", (PyCFunction)(void(*)(void))math_isclose, METH_FASTCALL|METH_KEYWORDS, math_isclose__doc__}, + {"isclose", (PyCFunction)(void(*)(void))math_isclose, METH_FASTCALL|METH_KEYWORDS, math_isclose__doc__}, static int math_isclose_impl(PyObject *module, double a, double b, double rel_tol, @@ -579,68 +579,68 @@ math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; double a; double b; double rel_tol = 1e-09; double abs_tol = 0.0; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } - if (PyFloat_CheckExact(args[0])) { - a = PyFloat_AS_DOUBLE(args[0]); - } - else - { - a = PyFloat_AsDouble(args[0]); - if (a == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - b = PyFloat_AS_DOUBLE(args[1]); - } - else - { - b = PyFloat_AsDouble(args[1]); - if (b == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (PyFloat_CheckExact(args[2])) { - rel_tol = PyFloat_AS_DOUBLE(args[2]); - } - else - { - rel_tol = PyFloat_AsDouble(args[2]); - if (rel_tol == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (PyFloat_CheckExact(args[3])) { - abs_tol = PyFloat_AS_DOUBLE(args[3]); - } - else - { - abs_tol = PyFloat_AsDouble(args[3]); - if (abs_tol == -1.0 && PyErr_Occurred()) { - goto exit; - } - } -skip_optional_kwonly: + if (PyFloat_CheckExact(args[0])) { + a = PyFloat_AS_DOUBLE(args[0]); + } + else + { + a = PyFloat_AsDouble(args[0]); + if (a == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + b = PyFloat_AS_DOUBLE(args[1]); + } + else + { + b = PyFloat_AsDouble(args[1]); + if (b == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (PyFloat_CheckExact(args[2])) { + rel_tol = PyFloat_AS_DOUBLE(args[2]); + } + else + { + rel_tol = PyFloat_AsDouble(args[2]); + if (rel_tol == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_CheckExact(args[3])) { + abs_tol = PyFloat_AS_DOUBLE(args[3]); + } + else + { + abs_tol = PyFloat_AsDouble(args[3]); + if (abs_tol == -1.0 && PyErr_Occurred()) { + goto exit; + } + } +skip_optional_kwonly: _return_value = math_isclose_impl(module, a, b, rel_tol, abs_tol); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -650,219 +650,219 @@ skip_optional_kwonly: exit: return return_value; } - -PyDoc_STRVAR(math_prod__doc__, -"prod($module, iterable, /, *, start=1)\n" -"--\n" -"\n" -"Calculate the product of all the elements in the input iterable.\n" -"\n" -"The default start value for the product is 1.\n" -"\n" -"When the iterable is empty, return the start value. This function is\n" -"intended specifically for use with numeric values and may reject\n" -"non-numeric types."); - -#define MATH_PROD_METHODDEF \ - {"prod", (PyCFunction)(void(*)(void))math_prod, METH_FASTCALL|METH_KEYWORDS, math_prod__doc__}, - -static PyObject * -math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start); - -static PyObject * -math_prod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "start", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "prod", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - PyObject *iterable; - PyObject *start = NULL; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - iterable = args[0]; - if (!noptargs) { - goto skip_optional_kwonly; - } - start = args[1]; -skip_optional_kwonly: - return_value = math_prod_impl(module, iterable, start); - -exit: - return return_value; -} - -PyDoc_STRVAR(math_perm__doc__, -"perm($module, n, k=None, /)\n" -"--\n" -"\n" -"Number of ways to choose k items from n items without repetition and with order.\n" -"\n" -"Evaluates to n! / (n - k)! when k <= n and evaluates\n" -"to zero when k > n.\n" -"\n" -"If k is not specified or is None, then k defaults to n\n" -"and the function returns n!.\n" -"\n" -"Raises TypeError if either of the arguments are not integers.\n" -"Raises ValueError if either of the arguments are negative."); - -#define MATH_PERM_METHODDEF \ - {"perm", (PyCFunction)(void(*)(void))math_perm, METH_FASTCALL, math_perm__doc__}, - -static PyObject * -math_perm_impl(PyObject *module, PyObject *n, PyObject *k); - -static PyObject * -math_perm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *n; - PyObject *k = Py_None; - - if (!_PyArg_CheckPositional("perm", nargs, 1, 2)) { - goto exit; - } - n = args[0]; - if (nargs < 2) { - goto skip_optional; - } - k = args[1]; -skip_optional: - return_value = math_perm_impl(module, n, k); - -exit: - return return_value; -} - -PyDoc_STRVAR(math_comb__doc__, -"comb($module, n, k, /)\n" -"--\n" -"\n" -"Number of ways to choose k items from n items without repetition and without order.\n" -"\n" -"Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates\n" -"to zero when k > n.\n" -"\n" -"Also called the binomial coefficient because it is equivalent\n" -"to the coefficient of k-th term in polynomial expansion of the\n" -"expression (1 + x)**n.\n" -"\n" -"Raises TypeError if either of the arguments are not integers.\n" -"Raises ValueError if either of the arguments are negative."); - -#define MATH_COMB_METHODDEF \ - {"comb", (PyCFunction)(void(*)(void))math_comb, METH_FASTCALL, math_comb__doc__}, - -static PyObject * -math_comb_impl(PyObject *module, PyObject *n, PyObject *k); - -static PyObject * -math_comb(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *n; - PyObject *k; - - if (!_PyArg_CheckPositional("comb", nargs, 2, 2)) { - goto exit; - } - n = args[0]; - k = args[1]; - return_value = math_comb_impl(module, n, k); - -exit: - return return_value; -} - -PyDoc_STRVAR(math_nextafter__doc__, -"nextafter($module, x, y, /)\n" -"--\n" -"\n" -"Return the next floating-point value after x towards y."); - -#define MATH_NEXTAFTER_METHODDEF \ - {"nextafter", (PyCFunction)(void(*)(void))math_nextafter, METH_FASTCALL, math_nextafter__doc__}, - -static PyObject * -math_nextafter_impl(PyObject *module, double x, double y); - -static PyObject * -math_nextafter(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - double x; - double y; - - if (!_PyArg_CheckPositional("nextafter", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_CheckExact(args[0])) { - x = PyFloat_AS_DOUBLE(args[0]); - } - else - { - x = PyFloat_AsDouble(args[0]); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - if (PyFloat_CheckExact(args[1])) { - y = PyFloat_AS_DOUBLE(args[1]); - } - else - { - y = PyFloat_AsDouble(args[1]); - if (y == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - return_value = math_nextafter_impl(module, x, y); - -exit: - return return_value; -} - -PyDoc_STRVAR(math_ulp__doc__, -"ulp($module, x, /)\n" -"--\n" -"\n" -"Return the value of the least significant bit of the float x."); - -#define MATH_ULP_METHODDEF \ - {"ulp", (PyCFunction)math_ulp, METH_O, math_ulp__doc__}, - -static double -math_ulp_impl(PyObject *module, double x); - -static PyObject * -math_ulp(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - double x; - double _return_value; - - if (PyFloat_CheckExact(arg)) { - x = PyFloat_AS_DOUBLE(arg); - } - else - { - x = PyFloat_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - goto exit; - } - } - _return_value = math_ulp_impl(module, x); - if ((_return_value == -1.0) && PyErr_Occurred()) { - goto exit; - } - return_value = PyFloat_FromDouble(_return_value); - -exit: - return return_value; -} -/*[clinic end generated code: output=1eae2b3ef19568fa input=a9049054013a1b77]*/ + +PyDoc_STRVAR(math_prod__doc__, +"prod($module, iterable, /, *, start=1)\n" +"--\n" +"\n" +"Calculate the product of all the elements in the input iterable.\n" +"\n" +"The default start value for the product is 1.\n" +"\n" +"When the iterable is empty, return the start value. This function is\n" +"intended specifically for use with numeric values and may reject\n" +"non-numeric types."); + +#define MATH_PROD_METHODDEF \ + {"prod", (PyCFunction)(void(*)(void))math_prod, METH_FASTCALL|METH_KEYWORDS, math_prod__doc__}, + +static PyObject * +math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start); + +static PyObject * +math_prod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "start", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "prod", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *iterable; + PyObject *start = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + iterable = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + start = args[1]; +skip_optional_kwonly: + return_value = math_prod_impl(module, iterable, start); + +exit: + return return_value; +} + +PyDoc_STRVAR(math_perm__doc__, +"perm($module, n, k=None, /)\n" +"--\n" +"\n" +"Number of ways to choose k items from n items without repetition and with order.\n" +"\n" +"Evaluates to n! / (n - k)! when k <= n and evaluates\n" +"to zero when k > n.\n" +"\n" +"If k is not specified or is None, then k defaults to n\n" +"and the function returns n!.\n" +"\n" +"Raises TypeError if either of the arguments are not integers.\n" +"Raises ValueError if either of the arguments are negative."); + +#define MATH_PERM_METHODDEF \ + {"perm", (PyCFunction)(void(*)(void))math_perm, METH_FASTCALL, math_perm__doc__}, + +static PyObject * +math_perm_impl(PyObject *module, PyObject *n, PyObject *k); + +static PyObject * +math_perm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *n; + PyObject *k = Py_None; + + if (!_PyArg_CheckPositional("perm", nargs, 1, 2)) { + goto exit; + } + n = args[0]; + if (nargs < 2) { + goto skip_optional; + } + k = args[1]; +skip_optional: + return_value = math_perm_impl(module, n, k); + +exit: + return return_value; +} + +PyDoc_STRVAR(math_comb__doc__, +"comb($module, n, k, /)\n" +"--\n" +"\n" +"Number of ways to choose k items from n items without repetition and without order.\n" +"\n" +"Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates\n" +"to zero when k > n.\n" +"\n" +"Also called the binomial coefficient because it is equivalent\n" +"to the coefficient of k-th term in polynomial expansion of the\n" +"expression (1 + x)**n.\n" +"\n" +"Raises TypeError if either of the arguments are not integers.\n" +"Raises ValueError if either of the arguments are negative."); + +#define MATH_COMB_METHODDEF \ + {"comb", (PyCFunction)(void(*)(void))math_comb, METH_FASTCALL, math_comb__doc__}, + +static PyObject * +math_comb_impl(PyObject *module, PyObject *n, PyObject *k); + +static PyObject * +math_comb(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *n; + PyObject *k; + + if (!_PyArg_CheckPositional("comb", nargs, 2, 2)) { + goto exit; + } + n = args[0]; + k = args[1]; + return_value = math_comb_impl(module, n, k); + +exit: + return return_value; +} + +PyDoc_STRVAR(math_nextafter__doc__, +"nextafter($module, x, y, /)\n" +"--\n" +"\n" +"Return the next floating-point value after x towards y."); + +#define MATH_NEXTAFTER_METHODDEF \ + {"nextafter", (PyCFunction)(void(*)(void))math_nextafter, METH_FASTCALL, math_nextafter__doc__}, + +static PyObject * +math_nextafter_impl(PyObject *module, double x, double y); + +static PyObject * +math_nextafter(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + double x; + double y; + + if (!_PyArg_CheckPositional("nextafter", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_CheckExact(args[0])) { + x = PyFloat_AS_DOUBLE(args[0]); + } + else + { + x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + y = PyFloat_AS_DOUBLE(args[1]); + } + else + { + y = PyFloat_AsDouble(args[1]); + if (y == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + return_value = math_nextafter_impl(module, x, y); + +exit: + return return_value; +} + +PyDoc_STRVAR(math_ulp__doc__, +"ulp($module, x, /)\n" +"--\n" +"\n" +"Return the value of the least significant bit of the float x."); + +#define MATH_ULP_METHODDEF \ + {"ulp", (PyCFunction)math_ulp, METH_O, math_ulp__doc__}, + +static double +math_ulp_impl(PyObject *module, double x); + +static PyObject * +math_ulp(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + double x; + double _return_value; + + if (PyFloat_CheckExact(arg)) { + x = PyFloat_AS_DOUBLE(arg); + } + else + { + x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + _return_value = math_ulp_impl(module, x); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=1eae2b3ef19568fa input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/md5module.c.h b/contrib/tools/python3/src/Modules/clinic/md5module.c.h index c109f9efec..0be9e3d749 100644 --- a/contrib/tools/python3/src/Modules/clinic/md5module.c.h +++ b/contrib/tools/python3/src/Modules/clinic/md5module.c.h @@ -66,53 +66,53 @@ PyDoc_STRVAR(MD5Type_update__doc__, {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__}, PyDoc_STRVAR(_md5_md5__doc__, -"md5($module, /, string=b\'\', *, usedforsecurity=True)\n" +"md5($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new MD5 hash object; optionally initialized with a string."); #define _MD5_MD5_METHODDEF \ - {"md5", (PyCFunction)(void(*)(void))_md5_md5, METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__}, + {"md5", (PyCFunction)(void(*)(void))_md5_md5, METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__}, static PyObject * -_md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity); +_md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "md5", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "md5", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _md5_md5_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _md5_md5_impl(module, string, usedforsecurity); exit: return return_value; } -/*[clinic end generated code: output=dbe3abc60086f3ef input=a9049054013a1b77]*/ +/*[clinic end generated code: output=dbe3abc60086f3ef input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h b/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h index 28798ab99c..5165752f12 100644 --- a/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h @@ -28,7 +28,7 @@ PyDoc_STRVAR(os_stat__doc__, " an open file descriptor."); #define OS_STAT_METHODDEF \ - {"stat", (PyCFunction)(void(*)(void))os_stat, METH_FASTCALL|METH_KEYWORDS, os_stat__doc__}, + {"stat", (PyCFunction)(void(*)(void))os_stat, METH_FASTCALL|METH_KEYWORDS, os_stat__doc__}, static PyObject * os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks); @@ -38,36 +38,36 @@ os_stat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1); int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[1]) { - if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[2]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); exit: @@ -87,7 +87,7 @@ PyDoc_STRVAR(os_lstat__doc__, "Equivalent to stat(path, follow_symlinks=False)."); #define OS_LSTAT_METHODDEF \ - {"lstat", (PyCFunction)(void(*)(void))os_lstat, METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, + {"lstat", (PyCFunction)(void(*)(void))os_lstat, METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, static PyObject * os_lstat_impl(PyObject *module, path_t *path, int dir_fd); @@ -97,26 +97,26 @@ os_lstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "lstat", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "lstat", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_lstat_impl(module, &path, dir_fd); exit: @@ -159,7 +159,7 @@ PyDoc_STRVAR(os_access__doc__, " has the specified access to the path."); #define OS_ACCESS_METHODDEF \ - {"access", (PyCFunction)(void(*)(void))os_access, METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, + {"access", (PyCFunction)(void(*)(void))os_access, METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, static int os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, @@ -170,9 +170,9 @@ os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "access", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "access", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("access", "path", 0, 0); int mode; int dir_fd = DEFAULT_DIR_FD; @@ -180,47 +180,47 @@ os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k int follow_symlinks = 1; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (!FACCESSAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - effective_ids = PyObject_IsTrue(args[3]); - if (effective_ids < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[4]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!FACCESSAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + effective_ids = PyObject_IsTrue(args[3]); + if (effective_ids < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -248,7 +248,7 @@ PyDoc_STRVAR(os_ttyname__doc__, #define OS_TTYNAME_METHODDEF \ {"ttyname", (PyCFunction)os_ttyname, METH_O, os_ttyname__doc__}, -static PyObject * +static PyObject * os_ttyname_impl(PyObject *module, int fd); static PyObject * @@ -257,16 +257,16 @@ os_ttyname(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { goto exit; } - return_value = os_ttyname_impl(module, fd); + return_value = os_ttyname_impl(module, fd); exit: return return_value; @@ -307,7 +307,7 @@ PyDoc_STRVAR(os_chdir__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_CHDIR_METHODDEF \ - {"chdir", (PyCFunction)(void(*)(void))os_chdir, METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, + {"chdir", (PyCFunction)(void(*)(void))os_chdir, METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, static PyObject * os_chdir_impl(PyObject *module, path_t *path); @@ -317,17 +317,17 @@ os_chdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "chdir", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "chdir", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } return_value = os_chdir_impl(module, &path); exit: @@ -349,7 +349,7 @@ PyDoc_STRVAR(os_fchdir__doc__, "Equivalent to os.chdir(fd)."); #define OS_FCHDIR_METHODDEF \ - {"fchdir", (PyCFunction)(void(*)(void))os_fchdir, METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, + {"fchdir", (PyCFunction)(void(*)(void))os_fchdir, METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, static PyObject * os_fchdir_impl(PyObject *module, int fd); @@ -359,17 +359,17 @@ os_fchdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fchdir", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "fchdir", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!fildes_converter(args[0], &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 = os_fchdir_impl(module, fd); exit: @@ -405,7 +405,7 @@ PyDoc_STRVAR(os_chmod__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHMOD_METHODDEF \ - {"chmod", (PyCFunction)(void(*)(void))os_chmod, METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, + {"chmod", (PyCFunction)(void(*)(void))os_chmod, METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, static PyObject * os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd, @@ -416,46 +416,46 @@ os_chmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "chmod", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "chmod", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD); int mode; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (!FCHMODAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[3]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!FCHMODAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[3]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); exit: @@ -476,7 +476,7 @@ PyDoc_STRVAR(os_fchmod__doc__, "Equivalent to os.chmod(fd, mode)."); #define OS_FCHMOD_METHODDEF \ - {"fchmod", (PyCFunction)(void(*)(void))os_fchmod, METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, + {"fchmod", (PyCFunction)(void(*)(void))os_fchmod, METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, static PyObject * os_fchmod_impl(PyObject *module, int fd, int mode); @@ -486,33 +486,33 @@ os_fchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "mode", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fchmod", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "fchmod", 0}; + PyObject *argsbuf[2]; int fd; int mode; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_fchmod_impl(module, fd, mode); exit: @@ -533,7 +533,7 @@ PyDoc_STRVAR(os_lchmod__doc__, "Equivalent to chmod(path, mode, follow_symlinks=False).\""); #define OS_LCHMOD_METHODDEF \ - {"lchmod", (PyCFunction)(void(*)(void))os_lchmod, METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, + {"lchmod", (PyCFunction)(void(*)(void))os_lchmod, METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, static PyObject * os_lchmod_impl(PyObject *module, path_t *path, int mode); @@ -543,27 +543,27 @@ os_lchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "lchmod", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "lchmod", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); int mode; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_lchmod_impl(module, &path, mode); exit: @@ -590,7 +590,7 @@ PyDoc_STRVAR(os_chflags__doc__, "unavailable, using it will raise a NotImplementedError."); #define OS_CHFLAGS_METHODDEF \ - {"chflags", (PyCFunction)(void(*)(void))os_chflags, METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, + {"chflags", (PyCFunction)(void(*)(void))os_chflags, METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, static PyObject * os_chflags_impl(PyObject *module, path_t *path, unsigned long flags, @@ -601,33 +601,33 @@ os_chflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "chflags", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "chflags", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0); unsigned long flags; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!PyLong_Check(args[1])) { - _PyArg_BadArgument("chflags", "argument 'flags'", "int", args[1]); - goto exit; - } - flags = PyLong_AsUnsignedLongMask(args[1]); - if (!noptargs) { - goto skip_optional_pos; - } - follow_symlinks = PyObject_IsTrue(args[2]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!PyLong_Check(args[1])) { + _PyArg_BadArgument("chflags", "argument 'flags'", "int", args[1]); + goto exit; + } + flags = PyLong_AsUnsignedLongMask(args[1]); + if (!noptargs) { + goto skip_optional_pos; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_pos: return_value = os_chflags_impl(module, &path, flags, follow_symlinks); exit: @@ -651,7 +651,7 @@ PyDoc_STRVAR(os_lchflags__doc__, "Equivalent to chflags(path, flags, follow_symlinks=False)."); #define OS_LCHFLAGS_METHODDEF \ - {"lchflags", (PyCFunction)(void(*)(void))os_lchflags, METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, + {"lchflags", (PyCFunction)(void(*)(void))os_lchflags, METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, static PyObject * os_lchflags_impl(PyObject *module, path_t *path, unsigned long flags); @@ -661,23 +661,23 @@ os_lchflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "lchflags", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "lchflags", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); unsigned long flags; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!PyLong_Check(args[1])) { - _PyArg_BadArgument("lchflags", "argument 'flags'", "int", args[1]); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } - flags = PyLong_AsUnsignedLongMask(args[1]); + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!PyLong_Check(args[1])) { + _PyArg_BadArgument("lchflags", "argument 'flags'", "int", args[1]); + goto exit; + } + flags = PyLong_AsUnsignedLongMask(args[1]); return_value = os_lchflags_impl(module, &path, flags); exit: @@ -698,7 +698,7 @@ PyDoc_STRVAR(os_chroot__doc__, "Change root directory to path."); #define OS_CHROOT_METHODDEF \ - {"chroot", (PyCFunction)(void(*)(void))os_chroot, METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, + {"chroot", (PyCFunction)(void(*)(void))os_chroot, METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, static PyObject * os_chroot_impl(PyObject *module, path_t *path); @@ -708,17 +708,17 @@ os_chroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "chroot", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "chroot", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } return_value = os_chroot_impl(module, &path); exit: @@ -739,7 +739,7 @@ PyDoc_STRVAR(os_fsync__doc__, "Force write of fd to disk."); #define OS_FSYNC_METHODDEF \ - {"fsync", (PyCFunction)(void(*)(void))os_fsync, METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, + {"fsync", (PyCFunction)(void(*)(void))os_fsync, METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, static PyObject * os_fsync_impl(PyObject *module, int fd); @@ -749,17 +749,17 @@ os_fsync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fsync", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "fsync", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!fildes_converter(args[0], &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 = os_fsync_impl(module, fd); exit: @@ -799,7 +799,7 @@ PyDoc_STRVAR(os_fdatasync__doc__, "Force write of fd to disk without forcing update of metadata."); #define OS_FDATASYNC_METHODDEF \ - {"fdatasync", (PyCFunction)(void(*)(void))os_fdatasync, METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, + {"fdatasync", (PyCFunction)(void(*)(void))os_fdatasync, METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, static PyObject * os_fdatasync_impl(PyObject *module, int fd); @@ -809,17 +809,17 @@ os_fdatasync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fdatasync", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "fdatasync", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!fildes_converter(args[0], &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 = os_fdatasync_impl(module, fd); exit: @@ -861,7 +861,7 @@ PyDoc_STRVAR(os_chown__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHOWN_METHODDEF \ - {"chown", (PyCFunction)(void(*)(void))os_chown, METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, + {"chown", (PyCFunction)(void(*)(void))os_chown, METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, static PyObject * os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid, @@ -872,44 +872,44 @@ os_chown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "chown", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + static _PyArg_Parser _parser = {NULL, _keywords, "chown", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN); uid_t uid; gid_t gid; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!_Py_Uid_Converter(args[1], &uid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[2], &gid)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[3]) { - if (!FCHOWNAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[4]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + if (!FCHOWNAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); exit: @@ -932,7 +932,7 @@ PyDoc_STRVAR(os_fchown__doc__, "Equivalent to os.chown(fd, uid, gid)."); #define OS_FCHOWN_METHODDEF \ - {"fchown", (PyCFunction)(void(*)(void))os_fchown, METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, + {"fchown", (PyCFunction)(void(*)(void))os_fchown, METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, static PyObject * os_fchown_impl(PyObject *module, int fd, uid_t uid, gid_t gid); @@ -942,31 +942,31 @@ os_fchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "uid", "gid", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fchown", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "fchown", 0}; + PyObject *argsbuf[3]; int fd; uid_t uid; gid_t gid; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!_Py_Uid_Converter(args[1], &uid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[2], &gid)) { - goto exit; - } + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { + goto exit; + } return_value = os_fchown_impl(module, fd, uid, gid); exit: @@ -987,7 +987,7 @@ PyDoc_STRVAR(os_lchown__doc__, "Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); #define OS_LCHOWN_METHODDEF \ - {"lchown", (PyCFunction)(void(*)(void))os_lchown, METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, + {"lchown", (PyCFunction)(void(*)(void))os_lchown, METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, static PyObject * os_lchown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid); @@ -997,25 +997,25 @@ os_lchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "uid", "gid", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "lchown", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "lchown", 0}; + PyObject *argsbuf[3]; path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0); uid_t uid; gid_t gid; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!_Py_Uid_Converter(args[1], &uid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[2], &gid)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { + goto exit; + } return_value = os_lchown_impl(module, &path, uid, gid); exit: @@ -1083,7 +1083,7 @@ PyDoc_STRVAR(os_link__doc__, " NotImplementedError."); #define OS_LINK_METHODDEF \ - {"link", (PyCFunction)(void(*)(void))os_link, METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, + {"link", (PyCFunction)(void(*)(void))os_link, METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, static PyObject * os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1094,49 +1094,49 @@ os_link(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "link", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "link", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("link", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &src)) { - goto exit; - } - if (!path_converter(args[1], &dst)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (!dir_fd_converter(args[2], &src_dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (!dir_fd_converter(args[3], &dst_dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[4]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!dir_fd_converter(args[3], &dst_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); exit: @@ -1168,7 +1168,7 @@ PyDoc_STRVAR(os_listdir__doc__, "entries \'.\' and \'..\' even if they are present in the directory."); #define OS_LISTDIR_METHODDEF \ - {"listdir", (PyCFunction)(void(*)(void))os_listdir, METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, + {"listdir", (PyCFunction)(void(*)(void))os_listdir, METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, static PyObject * os_listdir_impl(PyObject *module, path_t *path); @@ -1178,22 +1178,22 @@ os_listdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "listdir", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "listdir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (!path_converter(args[0], &path)) { + goto exit; + } +skip_optional_pos: return_value = os_listdir_impl(module, &path); exit: @@ -1222,7 +1222,7 @@ os__getfullpathname(PyObject *module, PyObject *arg) PyObject *return_value = NULL; path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0); - if (!path_converter(arg, &path)) { + if (!path_converter(arg, &path)) { goto exit; } return_value = os__getfullpathname_impl(module, &path); @@ -1256,7 +1256,7 @@ os__getfinalpathname(PyObject *module, PyObject *arg) PyObject *return_value = NULL; path_t path = PATH_T_INITIALIZE("_getfinalpathname", "path", 0, 0); - if (!path_converter(arg, &path)) { + if (!path_converter(arg, &path)) { goto exit; } return_value = os__getfinalpathname_impl(module, &path); @@ -1279,7 +1279,7 @@ PyDoc_STRVAR(os__getvolumepathname__doc__, "A helper function for ismount on Win32."); #define OS__GETVOLUMEPATHNAME_METHODDEF \ - {"_getvolumepathname", (PyCFunction)(void(*)(void))os__getvolumepathname, METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, + {"_getvolumepathname", (PyCFunction)(void(*)(void))os__getvolumepathname, METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, static PyObject * os__getvolumepathname_impl(PyObject *module, path_t *path); @@ -1289,17 +1289,17 @@ os__getvolumepathname(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_getvolumepathname", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "_getvolumepathname", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("_getvolumepathname", "path", 0, 0); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } return_value = os__getvolumepathname_impl(module, &path); exit: @@ -1311,47 +1311,47 @@ exit: #endif /* defined(MS_WINDOWS) */ -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(os__path_splitroot__doc__, -"_path_splitroot($module, /, path)\n" -"--\n" -"\n" -"Removes everything after the root on Win32."); - -#define OS__PATH_SPLITROOT_METHODDEF \ - {"_path_splitroot", (PyCFunction)(void(*)(void))os__path_splitroot, METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, - -static PyObject * -os__path_splitroot_impl(PyObject *module, path_t *path); - -static PyObject * -os__path_splitroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_path_splitroot", 0}; - PyObject *argsbuf[1]; - path_t path = PATH_T_INITIALIZE("_path_splitroot", "path", 0, 0); - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - return_value = os__path_splitroot_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__path_splitroot__doc__, +"_path_splitroot($module, /, path)\n" +"--\n" +"\n" +"Removes everything after the root on Win32."); + +#define OS__PATH_SPLITROOT_METHODDEF \ + {"_path_splitroot", (PyCFunction)(void(*)(void))os__path_splitroot, METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, + +static PyObject * +os__path_splitroot_impl(PyObject *module, path_t *path); + +static PyObject * +os__path_splitroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"path", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "_path_splitroot", 0}; + PyObject *argsbuf[1]; + path_t path = PATH_T_INITIALIZE("_path_splitroot", "path", 0, 0); + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + return_value = os__path_splitroot_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + PyDoc_STRVAR(os_mkdir__doc__, "mkdir($module, /, path, mode=511, *, dir_fd=None)\n" "--\n" @@ -1366,7 +1366,7 @@ PyDoc_STRVAR(os_mkdir__doc__, "The mode argument is ignored on Windows."); #define OS_MKDIR_METHODDEF \ - {"mkdir", (PyCFunction)(void(*)(void))os_mkdir, METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, + {"mkdir", (PyCFunction)(void(*)(void))os_mkdir, METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, static PyObject * os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd); @@ -1376,45 +1376,45 @@ os_mkdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "mkdir", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "mkdir", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0); int mode = 511; int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!MKDIRAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKDIRAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_mkdir_impl(module, &path, mode, dir_fd); exit: @@ -1444,15 +1444,15 @@ os_nice(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int increment; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - increment = _PyLong_AsInt(arg); - if (increment == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + increment = _PyLong_AsInt(arg); + if (increment == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_nice_impl(module, increment); exit: @@ -1470,7 +1470,7 @@ PyDoc_STRVAR(os_getpriority__doc__, "Return program scheduling priority."); #define OS_GETPRIORITY_METHODDEF \ - {"getpriority", (PyCFunction)(void(*)(void))os_getpriority, METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, + {"getpriority", (PyCFunction)(void(*)(void))os_getpriority, METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, static PyObject * os_getpriority_impl(PyObject *module, int which, int who); @@ -1480,33 +1480,33 @@ os_getpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"which", "who", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "getpriority", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "getpriority", 0}; + PyObject *argsbuf[2]; int which; int who; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - which = _PyLong_AsInt(args[0]); - if (which == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - who = _PyLong_AsInt(args[1]); - if (who == -1 && PyErr_Occurred()) { - goto exit; - } + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + which = _PyLong_AsInt(args[0]); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + who = _PyLong_AsInt(args[1]); + if (who == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_getpriority_impl(module, which, who); exit: @@ -1524,7 +1524,7 @@ PyDoc_STRVAR(os_setpriority__doc__, "Set program scheduling priority."); #define OS_SETPRIORITY_METHODDEF \ - {"setpriority", (PyCFunction)(void(*)(void))os_setpriority, METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, + {"setpriority", (PyCFunction)(void(*)(void))os_setpriority, METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, static PyObject * os_setpriority_impl(PyObject *module, int which, int who, int priority); @@ -1534,43 +1534,43 @@ os_setpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"which", "who", "priority", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "setpriority", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "setpriority", 0}; + PyObject *argsbuf[3]; int which; int who; int priority; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - which = _PyLong_AsInt(args[0]); - if (which == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - who = _PyLong_AsInt(args[1]); - if (who == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - priority = _PyLong_AsInt(args[2]); - if (priority == -1 && PyErr_Occurred()) { - goto exit; - } + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + which = _PyLong_AsInt(args[0]); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + who = _PyLong_AsInt(args[1]); + if (who == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + priority = _PyLong_AsInt(args[2]); + if (priority == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_setpriority_impl(module, which, who, priority); exit: @@ -1592,7 +1592,7 @@ PyDoc_STRVAR(os_rename__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_RENAME_METHODDEF \ - {"rename", (PyCFunction)(void(*)(void))os_rename, METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, + {"rename", (PyCFunction)(void(*)(void))os_rename, METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, static PyObject * os_rename_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1603,39 +1603,39 @@ os_rename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "rename", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "rename", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &src)) { - goto exit; - } - if (!path_converter(args[1], &dst)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (!dir_fd_converter(args[2], &src_dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (!dir_fd_converter(args[3], &dst_dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!dir_fd_converter(args[3], &dst_dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); exit: @@ -1660,7 +1660,7 @@ PyDoc_STRVAR(os_replace__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))os_replace, METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, + {"replace", (PyCFunction)(void(*)(void))os_replace, METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, static PyObject * os_replace_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1671,39 +1671,39 @@ os_replace(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &src)) { - goto exit; - } - if (!path_converter(args[1], &dst)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - if (!dir_fd_converter(args[2], &src_dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (!dir_fd_converter(args[3], &dst_dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!dir_fd_converter(args[3], &dst_dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); exit: @@ -1727,7 +1727,7 @@ PyDoc_STRVAR(os_rmdir__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_RMDIR_METHODDEF \ - {"rmdir", (PyCFunction)(void(*)(void))os_rmdir, METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, + {"rmdir", (PyCFunction)(void(*)(void))os_rmdir, METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, static PyObject * os_rmdir_impl(PyObject *module, path_t *path, int dir_fd); @@ -1737,26 +1737,26 @@ os_rmdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "rmdir", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "rmdir", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_rmdir_impl(module, &path, dir_fd); exit: @@ -1775,7 +1775,7 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, + {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, static long os_system_impl(PyObject *module, const Py_UNICODE *command); @@ -1814,7 +1814,7 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, + {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, static long os_system_impl(PyObject *module, PyObject *command); @@ -1824,18 +1824,18 @@ os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"command", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "system", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "system", 0}; + PyObject *argsbuf[1]; PyObject *command = NULL; long _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_FSConverter(args[0], &command)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!PyUnicode_FSConverter(args[0], &command)) { + goto exit; + } _return_value = os_system_impl(module, command); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -1869,15 +1869,15 @@ os_umask(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int mask; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mask = _PyLong_AsInt(arg); - if (mask == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + mask = _PyLong_AsInt(arg); + if (mask == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_umask_impl(module, mask); exit: @@ -1896,7 +1896,7 @@ PyDoc_STRVAR(os_unlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_UNLINK_METHODDEF \ - {"unlink", (PyCFunction)(void(*)(void))os_unlink, METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, + {"unlink", (PyCFunction)(void(*)(void))os_unlink, METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, static PyObject * os_unlink_impl(PyObject *module, path_t *path, int dir_fd); @@ -1906,26 +1906,26 @@ os_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "unlink", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "unlink", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_kwonly: + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_unlink_impl(module, &path, dir_fd); exit: @@ -1947,7 +1947,7 @@ PyDoc_STRVAR(os_remove__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_REMOVE_METHODDEF \ - {"remove", (PyCFunction)(void(*)(void))os_remove, METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, + {"remove", (PyCFunction)(void(*)(void))os_remove, METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, static PyObject * os_remove_impl(PyObject *module, path_t *path, int dir_fd); @@ -1957,26 +1957,26 @@ os_remove(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "remove", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "remove", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_kwonly: + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_remove_impl(module, &path, dir_fd); exit: @@ -2012,8 +2012,8 @@ os_uname(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_UNAME) */ PyDoc_STRVAR(os_utime__doc__, -"utime($module, /, path, times=None, *, ns=<unrepresentable>,\n" -" dir_fd=None, follow_symlinks=True)\n" +"utime($module, /, path, times=None, *, ns=<unrepresentable>,\n" +" dir_fd=None, follow_symlinks=True)\n" "--\n" "\n" "Set the access and modified time of path.\n" @@ -2041,7 +2041,7 @@ PyDoc_STRVAR(os_utime__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_UTIME_METHODDEF \ - {"utime", (PyCFunction)(void(*)(void))os_utime, METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, + {"utime", (PyCFunction)(void(*)(void))os_utime, METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, static PyObject * os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, @@ -2052,54 +2052,54 @@ os_utime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "utime", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "utime", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD); - PyObject *times = Py_None; + PyObject *times = Py_None; PyObject *ns = NULL; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - times = args[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[2]) { - ns = args[2]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (!FUTIMENSAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - follow_symlinks = PyObject_IsTrue(args[4]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + times = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + ns = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!FUTIMENSAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); exit: @@ -2116,7 +2116,7 @@ PyDoc_STRVAR(os__exit__doc__, "Exit to the system with specified status, without normal exit processing."); #define OS__EXIT_METHODDEF \ - {"_exit", (PyCFunction)(void(*)(void))os__exit, METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, + {"_exit", (PyCFunction)(void(*)(void))os__exit, METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, static PyObject * os__exit_impl(PyObject *module, int status); @@ -2126,23 +2126,23 @@ os__exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_exit", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "_exit", 0}; + PyObject *argsbuf[1]; int status; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os__exit_impl(module, status); exit: @@ -2163,7 +2163,7 @@ PyDoc_STRVAR(os_execv__doc__, " Tuple or list of strings."); #define OS_EXECV_METHODDEF \ - {"execv", (PyCFunction)(void(*)(void))os_execv, METH_FASTCALL, os_execv__doc__}, + {"execv", (PyCFunction)(void(*)(void))os_execv, METH_FASTCALL, os_execv__doc__}, static PyObject * os_execv_impl(PyObject *module, path_t *path, PyObject *argv); @@ -2175,13 +2175,13 @@ os_execv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) path_t path = PATH_T_INITIALIZE("execv", "path", 0, 0); PyObject *argv; - if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) { goto exit; } - if (!path_converter(args[0], &path)) { - goto exit; - } - argv = args[1]; + if (!path_converter(args[0], &path)) { + goto exit; + } + argv = args[1]; return_value = os_execv_impl(module, &path, argv); exit: @@ -2209,7 +2209,7 @@ PyDoc_STRVAR(os_execve__doc__, " Dictionary of strings mapping to strings."); #define OS_EXECVE_METHODDEF \ - {"execve", (PyCFunction)(void(*)(void))os_execve, METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, + {"execve", (PyCFunction)(void(*)(void))os_execve, METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, static PyObject * os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env); @@ -2219,21 +2219,21 @@ os_execve(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "argv", "env", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "execve", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "execve", 0}; + PyObject *argsbuf[3]; path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE); PyObject *argv; PyObject *env; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } - argv = args[1]; - env = args[2]; + if (!path_converter(args[0], &path)) { + goto exit; + } + argv = args[1]; + env = args[2]; return_value = os_execve_impl(module, &path, argv, env); exit: @@ -2245,282 +2245,282 @@ exit: #endif /* defined(HAVE_EXECV) */ -#if defined(HAVE_POSIX_SPAWN) - -PyDoc_STRVAR(os_posix_spawn__doc__, -"posix_spawn($module, path, argv, env, /, *, file_actions=(),\n" -" setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" -" setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" -"--\n" -"\n" -"Execute the program specified by path in a new process.\n" -"\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings.\n" -" env\n" -" Dictionary of strings mapping to strings.\n" -" file_actions\n" -" A sequence of file action tuples.\n" -" setpgroup\n" -" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" -" resetids\n" -" If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.\n" -" setsid\n" -" If the value is `true` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" -" setsigmask\n" -" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" -" setsigdef\n" -" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" -" scheduler\n" -" A tuple with the scheduler policy (optional) and parameters."); - -#define OS_POSIX_SPAWN_METHODDEF \ - {"posix_spawn", (PyCFunction)(void(*)(void))os_posix_spawn, METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, - -static PyObject * -os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv, - PyObject *env, PyObject *file_actions, - PyObject *setpgroup, int resetids, int setsid, - PyObject *setsigmask, PyObject *setsigdef, - PyObject *scheduler); - -static PyObject * -os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawn", 0}; - PyObject *argsbuf[10]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; - path_t path = PATH_T_INITIALIZE("posix_spawn", "path", 0, 0); - PyObject *argv; - PyObject *env; - PyObject *file_actions = NULL; - PyObject *setpgroup = NULL; - int resetids = 0; - int setsid = 0; - PyObject *setsigmask = NULL; - PyObject *setsigdef = NULL; - PyObject *scheduler = NULL; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - argv = args[1]; - env = args[2]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[3]) { - file_actions = args[3]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[4]) { - setpgroup = args[4]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[5]) { - if (PyFloat_Check(args[5])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - resetids = _PyLong_AsInt(args[5]); - if (resetids == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[6]) { - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - setsid = _PyLong_AsInt(args[6]); - if (setsid == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[7]) { - setsigmask = args[7]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[8]) { - setsigdef = args[8]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - scheduler = args[9]; -skip_optional_kwonly: - return_value = os_posix_spawn_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#endif /* defined(HAVE_POSIX_SPAWN) */ - -#if defined(HAVE_POSIX_SPAWNP) - -PyDoc_STRVAR(os_posix_spawnp__doc__, -"posix_spawnp($module, path, argv, env, /, *, file_actions=(),\n" -" setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" -" setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" -"--\n" -"\n" -"Execute the program specified by path in a new process.\n" -"\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings.\n" -" env\n" -" Dictionary of strings mapping to strings.\n" -" file_actions\n" -" A sequence of file action tuples.\n" -" setpgroup\n" -" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" -" resetids\n" -" If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.\n" -" setsid\n" -" If the value is `True` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" -" setsigmask\n" -" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" -" setsigdef\n" -" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" -" scheduler\n" -" A tuple with the scheduler policy (optional) and parameters."); - -#define OS_POSIX_SPAWNP_METHODDEF \ - {"posix_spawnp", (PyCFunction)(void(*)(void))os_posix_spawnp, METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, - -static PyObject * -os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv, - PyObject *env, PyObject *file_actions, - PyObject *setpgroup, int resetids, int setsid, - PyObject *setsigmask, PyObject *setsigdef, - PyObject *scheduler); - -static PyObject * -os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawnp", 0}; - PyObject *argsbuf[10]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; - path_t path = PATH_T_INITIALIZE("posix_spawnp", "path", 0, 0); - PyObject *argv; - PyObject *env; - PyObject *file_actions = NULL; - PyObject *setpgroup = NULL; - int resetids = 0; - int setsid = 0; - PyObject *setsigmask = NULL; - PyObject *setsigdef = NULL; - PyObject *scheduler = NULL; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - argv = args[1]; - env = args[2]; - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[3]) { - file_actions = args[3]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[4]) { - setpgroup = args[4]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[5]) { - if (PyFloat_Check(args[5])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - resetids = _PyLong_AsInt(args[5]); - if (resetids == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[6]) { - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - setsid = _PyLong_AsInt(args[6]); - if (setsid == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[7]) { - setsigmask = args[7]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[8]) { - setsigdef = args[8]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - scheduler = args[9]; -skip_optional_kwonly: - return_value = os_posix_spawnp_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#endif /* defined(HAVE_POSIX_SPAWNP) */ - -#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) - +#if defined(HAVE_POSIX_SPAWN) + +PyDoc_STRVAR(os_posix_spawn__doc__, +"posix_spawn($module, path, argv, env, /, *, file_actions=(),\n" +" setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" +" setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" +"--\n" +"\n" +"Execute the program specified by path in a new process.\n" +"\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings.\n" +" env\n" +" Dictionary of strings mapping to strings.\n" +" file_actions\n" +" A sequence of file action tuples.\n" +" setpgroup\n" +" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" +" resetids\n" +" If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.\n" +" setsid\n" +" If the value is `true` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" +" setsigmask\n" +" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" +" setsigdef\n" +" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" +" scheduler\n" +" A tuple with the scheduler policy (optional) and parameters."); + +#define OS_POSIX_SPAWN_METHODDEF \ + {"posix_spawn", (PyCFunction)(void(*)(void))os_posix_spawn, METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, + +static PyObject * +os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv, + PyObject *env, PyObject *file_actions, + PyObject *setpgroup, int resetids, int setsid, + PyObject *setsigmask, PyObject *setsigdef, + PyObject *scheduler); + +static PyObject * +os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawn", 0}; + PyObject *argsbuf[10]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + path_t path = PATH_T_INITIALIZE("posix_spawn", "path", 0, 0); + PyObject *argv; + PyObject *env; + PyObject *file_actions = NULL; + PyObject *setpgroup = NULL; + int resetids = 0; + int setsid = 0; + PyObject *setsigmask = NULL; + PyObject *setsigdef = NULL; + PyObject *scheduler = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + argv = args[1]; + env = args[2]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + file_actions = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + setpgroup = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + resetids = _PyLong_AsInt(args[5]); + if (resetids == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + setsid = _PyLong_AsInt(args[6]); + if (setsid == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[7]) { + setsigmask = args[7]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[8]) { + setsigdef = args[8]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + scheduler = args[9]; +skip_optional_kwonly: + return_value = os_posix_spawn_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_POSIX_SPAWN) */ + +#if defined(HAVE_POSIX_SPAWNP) + +PyDoc_STRVAR(os_posix_spawnp__doc__, +"posix_spawnp($module, path, argv, env, /, *, file_actions=(),\n" +" setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" +" setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" +"--\n" +"\n" +"Execute the program specified by path in a new process.\n" +"\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings.\n" +" env\n" +" Dictionary of strings mapping to strings.\n" +" file_actions\n" +" A sequence of file action tuples.\n" +" setpgroup\n" +" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" +" resetids\n" +" If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.\n" +" setsid\n" +" If the value is `True` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" +" setsigmask\n" +" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" +" setsigdef\n" +" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" +" scheduler\n" +" A tuple with the scheduler policy (optional) and parameters."); + +#define OS_POSIX_SPAWNP_METHODDEF \ + {"posix_spawnp", (PyCFunction)(void(*)(void))os_posix_spawnp, METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, + +static PyObject * +os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv, + PyObject *env, PyObject *file_actions, + PyObject *setpgroup, int resetids, int setsid, + PyObject *setsigmask, PyObject *setsigdef, + PyObject *scheduler); + +static PyObject * +os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawnp", 0}; + PyObject *argsbuf[10]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + path_t path = PATH_T_INITIALIZE("posix_spawnp", "path", 0, 0); + PyObject *argv; + PyObject *env; + PyObject *file_actions = NULL; + PyObject *setpgroup = NULL; + int resetids = 0; + int setsid = 0; + PyObject *setsigmask = NULL; + PyObject *setsigdef = NULL; + PyObject *scheduler = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + argv = args[1]; + env = args[2]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + file_actions = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + setpgroup = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + resetids = _PyLong_AsInt(args[5]); + if (resetids == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + setsid = _PyLong_AsInt(args[6]); + if (setsid == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[7]) { + setsigmask = args[7]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[8]) { + setsigdef = args[8]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + scheduler = args[9]; +skip_optional_kwonly: + return_value = os_posix_spawnp_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_POSIX_SPAWNP) */ + +#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) + PyDoc_STRVAR(os_spawnv__doc__, "spawnv($module, mode, path, argv, /)\n" "--\n" @@ -2535,7 +2535,7 @@ PyDoc_STRVAR(os_spawnv__doc__, " Tuple or list of strings."); #define OS_SPAWNV_METHODDEF \ - {"spawnv", (PyCFunction)(void(*)(void))os_spawnv, METH_FASTCALL, os_spawnv__doc__}, + {"spawnv", (PyCFunction)(void(*)(void))os_spawnv, METH_FASTCALL, os_spawnv__doc__}, static PyObject * os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv); @@ -2548,22 +2548,22 @@ os_spawnv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) path_t path = PATH_T_INITIALIZE("spawnv", "path", 0, 0); PyObject *argv; - if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[0]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!path_converter(args[1], &path)) { - goto exit; - } - argv = args[2]; + if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[0]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!path_converter(args[1], &path)) { + goto exit; + } + argv = args[2]; return_value = os_spawnv_impl(module, mode, &path, argv); exit: @@ -2573,9 +2573,9 @@ exit: return return_value; } -#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ +#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ -#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) +#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) PyDoc_STRVAR(os_spawnve__doc__, "spawnve($module, mode, path, argv, env, /)\n" @@ -2593,7 +2593,7 @@ PyDoc_STRVAR(os_spawnve__doc__, " Dictionary of strings mapping to strings."); #define OS_SPAWNVE_METHODDEF \ - {"spawnve", (PyCFunction)(void(*)(void))os_spawnve, METH_FASTCALL, os_spawnve__doc__}, + {"spawnve", (PyCFunction)(void(*)(void))os_spawnve, METH_FASTCALL, os_spawnve__doc__}, static PyObject * os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, @@ -2608,23 +2608,23 @@ os_spawnve(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *argv; PyObject *env; - if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[0]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!path_converter(args[1], &path)) { - goto exit; - } - argv = args[2]; - env = args[3]; + if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[0]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!path_converter(args[1], &path)) { + goto exit; + } + argv = args[2]; + env = args[3]; return_value = os_spawnve_impl(module, mode, &path, argv, env); exit: @@ -2634,14 +2634,14 @@ exit: return return_value; } -#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ +#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ #if defined(HAVE_FORK) PyDoc_STRVAR(os_register_at_fork__doc__, -"register_at_fork($module, /, *, before=<unrepresentable>,\n" -" after_in_child=<unrepresentable>,\n" -" after_in_parent=<unrepresentable>)\n" +"register_at_fork($module, /, *, before=<unrepresentable>,\n" +" after_in_child=<unrepresentable>,\n" +" after_in_parent=<unrepresentable>)\n" "--\n" "\n" "Register callables to be called when forking a new process.\n" @@ -2657,7 +2657,7 @@ PyDoc_STRVAR(os_register_at_fork__doc__, "\'after_in_child\' and \'after_in_parent\' callbacks are called in order."); #define OS_REGISTER_AT_FORK_METHODDEF \ - {"register_at_fork", (PyCFunction)(void(*)(void))os_register_at_fork, METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, + {"register_at_fork", (PyCFunction)(void(*)(void))os_register_at_fork, METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, static PyObject * os_register_at_fork_impl(PyObject *module, PyObject *before, @@ -2668,34 +2668,34 @@ os_register_at_fork(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"before", "after_in_child", "after_in_parent", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "register_at_fork", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "register_at_fork", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *before = NULL; PyObject *after_in_child = NULL; PyObject *after_in_parent = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[0]) { - before = args[0]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[1]) { - after_in_child = args[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - after_in_parent = args[2]; -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + before = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + after_in_child = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + after_in_parent = args[2]; +skip_optional_kwonly: return_value = os_register_at_fork_impl(module, before, after_in_child, after_in_parent); exit: @@ -2761,7 +2761,7 @@ PyDoc_STRVAR(os_sched_get_priority_max__doc__, "Get the maximum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ - {"sched_get_priority_max", (PyCFunction)(void(*)(void))os_sched_get_priority_max, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, + {"sched_get_priority_max", (PyCFunction)(void(*)(void))os_sched_get_priority_max, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, static PyObject * os_sched_get_priority_max_impl(PyObject *module, int policy); @@ -2771,23 +2771,23 @@ os_sched_get_priority_max(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"policy", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_max", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_max", 0}; + PyObject *argsbuf[1]; int policy; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - policy = _PyLong_AsInt(args[0]); - if (policy == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + policy = _PyLong_AsInt(args[0]); + if (policy == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_sched_get_priority_max_impl(module, policy); exit: @@ -2805,7 +2805,7 @@ PyDoc_STRVAR(os_sched_get_priority_min__doc__, "Get the minimum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ - {"sched_get_priority_min", (PyCFunction)(void(*)(void))os_sched_get_priority_min, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, + {"sched_get_priority_min", (PyCFunction)(void(*)(void))os_sched_get_priority_min, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, static PyObject * os_sched_get_priority_min_impl(PyObject *module, int policy); @@ -2815,23 +2815,23 @@ os_sched_get_priority_min(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"policy", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_min", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_min", 0}; + PyObject *argsbuf[1]; int policy; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - policy = _PyLong_AsInt(args[0]); - if (policy == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + policy = _PyLong_AsInt(args[0]); + if (policy == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_sched_get_priority_min_impl(module, policy); exit: @@ -2846,7 +2846,7 @@ PyDoc_STRVAR(os_sched_getscheduler__doc__, "sched_getscheduler($module, pid, /)\n" "--\n" "\n" -"Get the scheduling policy for the process identified by pid.\n" +"Get the scheduling policy for the process identified by pid.\n" "\n" "Passing 0 for pid returns the scheduling policy for the calling process."); @@ -2873,13 +2873,13 @@ exit: #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ -#if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) +#if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) PyDoc_STRVAR(os_sched_param__doc__, "sched_param(sched_priority)\n" "--\n" "\n" -"Currently has only one field: sched_priority\n" +"Currently has only one field: sched_priority\n" "\n" " sched_priority\n" " A scheduling parameter."); @@ -2892,24 +2892,24 @@ os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sched_priority", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sched_param", 0}; - PyObject *argsbuf[1]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); + static _PyArg_Parser _parser = {NULL, _keywords, "sched_param", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *sched_priority; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - sched_priority = fastargs[0]; + sched_priority = fastargs[0]; return_value = os_sched_param_impl(type, sched_priority); exit: return return_value; } -#endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) */ +#endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) */ #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) @@ -2923,11 +2923,11 @@ PyDoc_STRVAR(os_sched_setscheduler__doc__, "param is an instance of sched_param."); #define OS_SCHED_SETSCHEDULER_METHODDEF \ - {"sched_setscheduler", (PyCFunction)(void(*)(void))os_sched_setscheduler, METH_FASTCALL, os_sched_setscheduler__doc__}, + {"sched_setscheduler", (PyCFunction)(void(*)(void))os_sched_setscheduler, METH_FASTCALL, os_sched_setscheduler__doc__}, static PyObject * os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy, - PyObject *param_obj); + PyObject *param_obj); static PyObject * os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) @@ -2935,13 +2935,13 @@ os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; pid_t pid; int policy; - PyObject *param_obj; + PyObject *param_obj; - if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "iO:sched_setscheduler", - &pid, &policy, ¶m_obj)) { + if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "iO:sched_setscheduler", + &pid, &policy, ¶m_obj)) { goto exit; } - return_value = os_sched_setscheduler_impl(module, pid, policy, param_obj); + return_value = os_sched_setscheduler_impl(module, pid, policy, param_obj); exit: return return_value; @@ -2995,23 +2995,23 @@ PyDoc_STRVAR(os_sched_setparam__doc__, "param should be an instance of sched_param."); #define OS_SCHED_SETPARAM_METHODDEF \ - {"sched_setparam", (PyCFunction)(void(*)(void))os_sched_setparam, METH_FASTCALL, os_sched_setparam__doc__}, + {"sched_setparam", (PyCFunction)(void(*)(void))os_sched_setparam, METH_FASTCALL, os_sched_setparam__doc__}, static PyObject * -os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); +os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); static PyObject * os_sched_setparam(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; pid_t pid; - PyObject *param_obj; + PyObject *param_obj; - if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O:sched_setparam", - &pid, ¶m_obj)) { + if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O:sched_setparam", + &pid, ¶m_obj)) { goto exit; } - return_value = os_sched_setparam_impl(module, pid, param_obj); + return_value = os_sched_setparam_impl(module, pid, param_obj); exit: return return_value; @@ -3090,7 +3090,7 @@ PyDoc_STRVAR(os_sched_setaffinity__doc__, "mask should be an iterable of integers identifying CPUs."); #define OS_SCHED_SETAFFINITY_METHODDEF \ - {"sched_setaffinity", (PyCFunction)(void(*)(void))os_sched_setaffinity, METH_FASTCALL, os_sched_setaffinity__doc__}, + {"sched_setaffinity", (PyCFunction)(void(*)(void))os_sched_setaffinity, METH_FASTCALL, os_sched_setaffinity__doc__}, static PyObject * os_sched_setaffinity_impl(PyObject *module, pid_t pid, PyObject *mask); @@ -3287,118 +3287,118 @@ os_getpid(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_GETPID) */ -#if defined(HAVE_GETGROUPLIST) && defined(__APPLE__) - -PyDoc_STRVAR(os_getgrouplist__doc__, -"getgrouplist($module, user, group, /)\n" -"--\n" -"\n" -"Returns a list of groups to which a user belongs.\n" -"\n" -" user\n" -" username to lookup\n" -" group\n" -" base group id of the user"); - -#define OS_GETGROUPLIST_METHODDEF \ - {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, - -static PyObject * -os_getgrouplist_impl(PyObject *module, const char *user, int basegid); - -static PyObject * -os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const char *user; - int basegid; - - if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t user_length; - user = PyUnicode_AsUTF8AndSize(args[0], &user_length); - if (user == NULL) { - goto exit; - } - if (strlen(user) != (size_t)user_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - basegid = _PyLong_AsInt(args[1]); - if (basegid == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = os_getgrouplist_impl(module, user, basegid); - -exit: - return return_value; -} - -#endif /* defined(HAVE_GETGROUPLIST) && defined(__APPLE__) */ - -#if defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) - -PyDoc_STRVAR(os_getgrouplist__doc__, -"getgrouplist($module, user, group, /)\n" -"--\n" -"\n" -"Returns a list of groups to which a user belongs.\n" -"\n" -" user\n" -" username to lookup\n" -" group\n" -" base group id of the user"); - -#define OS_GETGROUPLIST_METHODDEF \ - {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, - -static PyObject * -os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid); - -static PyObject * -os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const char *user; - gid_t basegid; - - if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t user_length; - user = PyUnicode_AsUTF8AndSize(args[0], &user_length); - if (user == NULL) { - goto exit; - } - if (strlen(user) != (size_t)user_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!_Py_Gid_Converter(args[1], &basegid)) { - goto exit; - } - return_value = os_getgrouplist_impl(module, user, basegid); - -exit: - return return_value; -} - -#endif /* defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) */ - +#if defined(HAVE_GETGROUPLIST) && defined(__APPLE__) + +PyDoc_STRVAR(os_getgrouplist__doc__, +"getgrouplist($module, user, group, /)\n" +"--\n" +"\n" +"Returns a list of groups to which a user belongs.\n" +"\n" +" user\n" +" username to lookup\n" +" group\n" +" base group id of the user"); + +#define OS_GETGROUPLIST_METHODDEF \ + {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, + +static PyObject * +os_getgrouplist_impl(PyObject *module, const char *user, int basegid); + +static PyObject * +os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + const char *user; + int basegid; + + if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t user_length; + user = PyUnicode_AsUTF8AndSize(args[0], &user_length); + if (user == NULL) { + goto exit; + } + if (strlen(user) != (size_t)user_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + basegid = _PyLong_AsInt(args[1]); + if (basegid == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = os_getgrouplist_impl(module, user, basegid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETGROUPLIST) && defined(__APPLE__) */ + +#if defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) + +PyDoc_STRVAR(os_getgrouplist__doc__, +"getgrouplist($module, user, group, /)\n" +"--\n" +"\n" +"Returns a list of groups to which a user belongs.\n" +"\n" +" user\n" +" username to lookup\n" +" group\n" +" base group id of the user"); + +#define OS_GETGROUPLIST_METHODDEF \ + {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, + +static PyObject * +os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid); + +static PyObject * +os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + const char *user; + gid_t basegid; + + if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t user_length; + user = PyUnicode_AsUTF8AndSize(args[0], &user_length); + if (user == NULL) { + goto exit; + } + if (strlen(user) != (size_t)user_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!_Py_Gid_Converter(args[1], &basegid)) { + goto exit; + } + return_value = os_getgrouplist_impl(module, user, basegid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) */ + #if defined(HAVE_GETGROUPS) PyDoc_STRVAR(os_getgroups__doc__, @@ -3421,102 +3421,102 @@ os_getgroups(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_GETGROUPS) */ -#if defined(HAVE_INITGROUPS) && defined(__APPLE__) - -PyDoc_STRVAR(os_initgroups__doc__, -"initgroups($module, username, gid, /)\n" -"--\n" -"\n" -"Initialize the group access list.\n" -"\n" -"Call the system initgroups() to initialize the group access list with all of\n" -"the groups of which the specified username is a member, plus the specified\n" -"group id."); - -#define OS_INITGROUPS_METHODDEF \ - {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, - -static PyObject * -os_initgroups_impl(PyObject *module, PyObject *oname, int gid); - -static PyObject * -os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *oname = NULL; - int gid; - - if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_FSConverter(args[0], &oname)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - gid = _PyLong_AsInt(args[1]); - if (gid == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = os_initgroups_impl(module, oname, gid); - -exit: - /* Cleanup for oname */ - Py_XDECREF(oname); - - return return_value; -} - -#endif /* defined(HAVE_INITGROUPS) && defined(__APPLE__) */ - -#if defined(HAVE_INITGROUPS) && !defined(__APPLE__) - -PyDoc_STRVAR(os_initgroups__doc__, -"initgroups($module, username, gid, /)\n" -"--\n" -"\n" -"Initialize the group access list.\n" -"\n" -"Call the system initgroups() to initialize the group access list with all of\n" -"the groups of which the specified username is a member, plus the specified\n" -"group id."); - -#define OS_INITGROUPS_METHODDEF \ - {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, - -static PyObject * -os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid); - -static PyObject * -os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *oname = NULL; - gid_t gid; - - if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_FSConverter(args[0], &oname)) { - goto exit; - } - if (!_Py_Gid_Converter(args[1], &gid)) { - goto exit; - } - return_value = os_initgroups_impl(module, oname, gid); - -exit: - /* Cleanup for oname */ - Py_XDECREF(oname); - - return return_value; -} - -#endif /* defined(HAVE_INITGROUPS) && !defined(__APPLE__) */ - +#if defined(HAVE_INITGROUPS) && defined(__APPLE__) + +PyDoc_STRVAR(os_initgroups__doc__, +"initgroups($module, username, gid, /)\n" +"--\n" +"\n" +"Initialize the group access list.\n" +"\n" +"Call the system initgroups() to initialize the group access list with all of\n" +"the groups of which the specified username is a member, plus the specified\n" +"group id."); + +#define OS_INITGROUPS_METHODDEF \ + {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, + +static PyObject * +os_initgroups_impl(PyObject *module, PyObject *oname, int gid); + +static PyObject * +os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *oname = NULL; + int gid; + + if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_FSConverter(args[0], &oname)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + gid = _PyLong_AsInt(args[1]); + if (gid == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = os_initgroups_impl(module, oname, gid); + +exit: + /* Cleanup for oname */ + Py_XDECREF(oname); + + return return_value; +} + +#endif /* defined(HAVE_INITGROUPS) && defined(__APPLE__) */ + +#if defined(HAVE_INITGROUPS) && !defined(__APPLE__) + +PyDoc_STRVAR(os_initgroups__doc__, +"initgroups($module, username, gid, /)\n" +"--\n" +"\n" +"Initialize the group access list.\n" +"\n" +"Call the system initgroups() to initialize the group access list with all of\n" +"the groups of which the specified username is a member, plus the specified\n" +"group id."); + +#define OS_INITGROUPS_METHODDEF \ + {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, + +static PyObject * +os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid); + +static PyObject * +os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *oname = NULL; + gid_t gid; + + if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_FSConverter(args[0], &oname)) { + goto exit; + } + if (!_Py_Gid_Converter(args[1], &gid)) { + goto exit; + } + return_value = os_initgroups_impl(module, oname, gid); + +exit: + /* Cleanup for oname */ + Py_XDECREF(oname); + + return return_value; +} + +#endif /* defined(HAVE_INITGROUPS) && !defined(__APPLE__) */ + #if defined(HAVE_GETPGID) PyDoc_STRVAR(os_getpgid__doc__, @@ -3526,7 +3526,7 @@ PyDoc_STRVAR(os_getpgid__doc__, "Call the system call getpgid(), and return the result."); #define OS_GETPGID_METHODDEF \ - {"getpgid", (PyCFunction)(void(*)(void))os_getpgid, METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, + {"getpgid", (PyCFunction)(void(*)(void))os_getpgid, METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, static PyObject * os_getpgid_impl(PyObject *module, pid_t pid); @@ -3673,7 +3673,7 @@ PyDoc_STRVAR(os_kill__doc__, "Kill a process with a signal."); #define OS_KILL_METHODDEF \ - {"kill", (PyCFunction)(void(*)(void))os_kill, METH_FASTCALL, os_kill__doc__}, + {"kill", (PyCFunction)(void(*)(void))os_kill, METH_FASTCALL, os_kill__doc__}, static PyObject * os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal); @@ -3706,7 +3706,7 @@ PyDoc_STRVAR(os_killpg__doc__, "Kill a process group with a signal."); #define OS_KILLPG_METHODDEF \ - {"killpg", (PyCFunction)(void(*)(void))os_killpg, METH_FASTCALL, os_killpg__doc__}, + {"killpg", (PyCFunction)(void(*)(void))os_killpg, METH_FASTCALL, os_killpg__doc__}, static PyObject * os_killpg_impl(PyObject *module, pid_t pgid, int signal); @@ -3750,15 +3750,15 @@ os_plock(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int op; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - op = _PyLong_AsInt(arg); - if (op == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + op = _PyLong_AsInt(arg); + if (op == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_plock_impl(module, op); exit: @@ -3787,7 +3787,7 @@ os_setuid(PyObject *module, PyObject *arg) PyObject *return_value = NULL; uid_t uid; - if (!_Py_Uid_Converter(arg, &uid)) { + if (!_Py_Uid_Converter(arg, &uid)) { goto exit; } return_value = os_setuid_impl(module, uid); @@ -3818,7 +3818,7 @@ os_seteuid(PyObject *module, PyObject *arg) PyObject *return_value = NULL; uid_t euid; - if (!_Py_Uid_Converter(arg, &euid)) { + if (!_Py_Uid_Converter(arg, &euid)) { goto exit; } return_value = os_seteuid_impl(module, euid); @@ -3849,7 +3849,7 @@ os_setegid(PyObject *module, PyObject *arg) PyObject *return_value = NULL; gid_t egid; - if (!_Py_Gid_Converter(arg, &egid)) { + if (!_Py_Gid_Converter(arg, &egid)) { goto exit; } return_value = os_setegid_impl(module, egid); @@ -3869,7 +3869,7 @@ PyDoc_STRVAR(os_setreuid__doc__, "Set the current process\'s real and effective user ids."); #define OS_SETREUID_METHODDEF \ - {"setreuid", (PyCFunction)(void(*)(void))os_setreuid, METH_FASTCALL, os_setreuid__doc__}, + {"setreuid", (PyCFunction)(void(*)(void))os_setreuid, METH_FASTCALL, os_setreuid__doc__}, static PyObject * os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid); @@ -3881,15 +3881,15 @@ os_setreuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) uid_t ruid; uid_t euid; - if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) { - goto exit; - } - if (!_Py_Uid_Converter(args[0], &ruid)) { - goto exit; - } - if (!_Py_Uid_Converter(args[1], &euid)) { + if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) { goto exit; } + if (!_Py_Uid_Converter(args[0], &ruid)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &euid)) { + goto exit; + } return_value = os_setreuid_impl(module, ruid, euid); exit: @@ -3907,7 +3907,7 @@ PyDoc_STRVAR(os_setregid__doc__, "Set the current process\'s real and effective group ids."); #define OS_SETREGID_METHODDEF \ - {"setregid", (PyCFunction)(void(*)(void))os_setregid, METH_FASTCALL, os_setregid__doc__}, + {"setregid", (PyCFunction)(void(*)(void))os_setregid, METH_FASTCALL, os_setregid__doc__}, static PyObject * os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid); @@ -3919,15 +3919,15 @@ os_setregid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) gid_t rgid; gid_t egid; - if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) { - goto exit; - } - if (!_Py_Gid_Converter(args[0], &rgid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[1], &egid)) { + if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) { goto exit; } + if (!_Py_Gid_Converter(args[0], &rgid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[1], &egid)) { + goto exit; + } return_value = os_setregid_impl(module, rgid, egid); exit: @@ -3956,7 +3956,7 @@ os_setgid(PyObject *module, PyObject *arg) PyObject *return_value = NULL; gid_t gid; - if (!_Py_Gid_Converter(arg, &gid)) { + if (!_Py_Gid_Converter(arg, &gid)) { goto exit; } return_value = os_setgid_impl(module, gid); @@ -3992,7 +3992,7 @@ PyDoc_STRVAR(os_wait3__doc__, " (pid, status, rusage)"); #define OS_WAIT3_METHODDEF \ - {"wait3", (PyCFunction)(void(*)(void))os_wait3, METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, + {"wait3", (PyCFunction)(void(*)(void))os_wait3, METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, static PyObject * os_wait3_impl(PyObject *module, int options); @@ -4002,23 +4002,23 @@ os_wait3(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"options", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "wait3", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "wait3", 0}; + PyObject *argsbuf[1]; int options; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - options = _PyLong_AsInt(args[0]); - if (options == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + options = _PyLong_AsInt(args[0]); + if (options == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_wait3_impl(module, options); exit: @@ -4039,7 +4039,7 @@ PyDoc_STRVAR(os_wait4__doc__, " (pid, status, rusage)"); #define OS_WAIT4_METHODDEF \ - {"wait4", (PyCFunction)(void(*)(void))os_wait4, METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, + {"wait4", (PyCFunction)(void(*)(void))os_wait4, METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, static PyObject * os_wait4_impl(PyObject *module, pid_t pid, int options); @@ -4085,7 +4085,7 @@ PyDoc_STRVAR(os_waitid__doc__, "no children in a waitable state."); #define OS_WAITID_METHODDEF \ - {"waitid", (PyCFunction)(void(*)(void))os_waitid, METH_FASTCALL, os_waitid__doc__}, + {"waitid", (PyCFunction)(void(*)(void))os_waitid, METH_FASTCALL, os_waitid__doc__}, static PyObject * os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options); @@ -4124,7 +4124,7 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, + {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, pid_t pid, int options); @@ -4148,7 +4148,7 @@ exit: #endif /* defined(HAVE_WAITPID) */ -#if !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) +#if !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) PyDoc_STRVAR(os_waitpid__doc__, "waitpid($module, pid, options, /)\n" @@ -4162,7 +4162,7 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, + {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, intptr_t pid, int options); @@ -4184,7 +4184,7 @@ exit: return return_value; } -#endif /* !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) */ +#endif /* !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) */ #if defined(HAVE_WAIT) @@ -4211,100 +4211,100 @@ os_wait(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_WAIT) */ -#if (defined(__linux__) && defined(__NR_pidfd_open)) - -PyDoc_STRVAR(os_pidfd_open__doc__, -"pidfd_open($module, /, pid, flags=0)\n" -"--\n" -"\n" -"Return a file descriptor referring to the process *pid*.\n" -"\n" -"The descriptor can be used to perform process management without races and\n" -"signals."); - -#define OS_PIDFD_OPEN_METHODDEF \ - {"pidfd_open", (PyCFunction)(void(*)(void))os_pidfd_open, METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, - -static PyObject * -os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags); - -static PyObject * -os_pidfd_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"pid", "flags", NULL}; - static _PyArg_Parser _parser = {"" _Py_PARSE_PID "|O&:pidfd_open", _keywords, 0}; - pid_t pid; - unsigned int flags = 0; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &pid, _PyLong_UnsignedInt_Converter, &flags)) { - goto exit; - } - return_value = os_pidfd_open_impl(module, pid, flags); - -exit: - return return_value; -} - -#endif /* (defined(__linux__) && defined(__NR_pidfd_open)) */ - -#if (defined(HAVE_READLINK) || defined(MS_WINDOWS)) - -PyDoc_STRVAR(os_readlink__doc__, -"readlink($module, /, path, *, dir_fd=None)\n" -"--\n" -"\n" -"Return a string representing the path to which the symbolic link points.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -"and path should be relative; path will then be relative to that directory.\n" -"\n" -"dir_fd may not be implemented on your platform. If it is unavailable,\n" -"using it will raise a NotImplementedError."); - -#define OS_READLINK_METHODDEF \ - {"readlink", (PyCFunction)(void(*)(void))os_readlink, METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, - -static PyObject * -os_readlink_impl(PyObject *module, path_t *path, int dir_fd); - -static PyObject * -os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "readlink", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - path_t path = PATH_T_INITIALIZE("readlink", "path", 0, 0); - int dir_fd = DEFAULT_DIR_FD; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!READLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: - return_value = os_readlink_impl(module, &path, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#endif /* (defined(HAVE_READLINK) || defined(MS_WINDOWS)) */ - +#if (defined(__linux__) && defined(__NR_pidfd_open)) + +PyDoc_STRVAR(os_pidfd_open__doc__, +"pidfd_open($module, /, pid, flags=0)\n" +"--\n" +"\n" +"Return a file descriptor referring to the process *pid*.\n" +"\n" +"The descriptor can be used to perform process management without races and\n" +"signals."); + +#define OS_PIDFD_OPEN_METHODDEF \ + {"pidfd_open", (PyCFunction)(void(*)(void))os_pidfd_open, METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, + +static PyObject * +os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags); + +static PyObject * +os_pidfd_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"pid", "flags", NULL}; + static _PyArg_Parser _parser = {"" _Py_PARSE_PID "|O&:pidfd_open", _keywords, 0}; + pid_t pid; + unsigned int flags = 0; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &pid, _PyLong_UnsignedInt_Converter, &flags)) { + goto exit; + } + return_value = os_pidfd_open_impl(module, pid, flags); + +exit: + return return_value; +} + +#endif /* (defined(__linux__) && defined(__NR_pidfd_open)) */ + +#if (defined(HAVE_READLINK) || defined(MS_WINDOWS)) + +PyDoc_STRVAR(os_readlink__doc__, +"readlink($module, /, path, *, dir_fd=None)\n" +"--\n" +"\n" +"Return a string representing the path to which the symbolic link points.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +"and path should be relative; path will then be relative to that directory.\n" +"\n" +"dir_fd may not be implemented on your platform. If it is unavailable,\n" +"using it will raise a NotImplementedError."); + +#define OS_READLINK_METHODDEF \ + {"readlink", (PyCFunction)(void(*)(void))os_readlink, METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, + +static PyObject * +os_readlink_impl(PyObject *module, path_t *path, int dir_fd); + +static PyObject * +os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"path", "dir_fd", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "readlink", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + path_t path = PATH_T_INITIALIZE("readlink", "path", 0, 0); + int dir_fd = DEFAULT_DIR_FD; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!READLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: + return_value = os_readlink_impl(module, &path, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* (defined(HAVE_READLINK) || defined(MS_WINDOWS)) */ + #if defined(HAVE_SYMLINK) PyDoc_STRVAR(os_symlink__doc__, @@ -4324,7 +4324,7 @@ PyDoc_STRVAR(os_symlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_SYMLINK_METHODDEF \ - {"symlink", (PyCFunction)(void(*)(void))os_symlink, METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, + {"symlink", (PyCFunction)(void(*)(void))os_symlink, METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, static PyObject * os_symlink_impl(PyObject *module, path_t *src, path_t *dst, @@ -4335,44 +4335,44 @@ os_symlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "symlink", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "symlink", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0); int target_is_directory = 0; int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &src)) { - goto exit; - } - if (!path_converter(args[1], &dst)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - target_is_directory = PyObject_IsTrue(args[2]); - if (target_is_directory < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!SYMLINKAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + target_is_directory = PyObject_IsTrue(args[2]); + if (target_is_directory < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!SYMLINKAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); exit: @@ -4474,7 +4474,7 @@ PyDoc_STRVAR(os_setpgid__doc__, "Call the system call setpgid(pid, pgrp)."); #define OS_SETPGID_METHODDEF \ - {"setpgid", (PyCFunction)(void(*)(void))os_setpgid, METH_FASTCALL, os_setpgid__doc__}, + {"setpgid", (PyCFunction)(void(*)(void))os_setpgid, METH_FASTCALL, os_setpgid__doc__}, static PyObject * os_setpgid_impl(PyObject *module, pid_t pid, pid_t pgrp); @@ -4518,15 +4518,15 @@ os_tcgetpgrp(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_tcgetpgrp_impl(module, fd); exit: @@ -4544,7 +4544,7 @@ PyDoc_STRVAR(os_tcsetpgrp__doc__, "Set the process group associated with the terminal specified by fd."); #define OS_TCSETPGRP_METHODDEF \ - {"tcsetpgrp", (PyCFunction)(void(*)(void))os_tcsetpgrp, METH_FASTCALL, os_tcsetpgrp__doc__}, + {"tcsetpgrp", (PyCFunction)(void(*)(void))os_tcsetpgrp, METH_FASTCALL, os_tcsetpgrp__doc__}, static PyObject * os_tcsetpgrp_impl(PyObject *module, int fd, pid_t pgid); @@ -4580,7 +4580,7 @@ PyDoc_STRVAR(os_open__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_OPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))os_open, METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, + {"open", (PyCFunction)(void(*)(void))os_open, METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, static int os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd); @@ -4590,56 +4590,56 @@ os_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("open", "path", 0, 0); int flags; int mode = 511; int dir_fd = DEFAULT_DIR_FD; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[2]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!OPENAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[2]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!OPENAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: _return_value = os_open_impl(module, &path, flags, mode, dir_fd); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -4660,7 +4660,7 @@ PyDoc_STRVAR(os_close__doc__, "Close a file descriptor."); #define OS_CLOSE_METHODDEF \ - {"close", (PyCFunction)(void(*)(void))os_close, METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, + {"close", (PyCFunction)(void(*)(void))os_close, METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, static PyObject * os_close_impl(PyObject *module, int fd); @@ -4670,23 +4670,23 @@ os_close(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "close", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "close", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_close_impl(module, fd); exit: @@ -4700,7 +4700,7 @@ PyDoc_STRVAR(os_closerange__doc__, "Closes all file descriptors in [fd_low, fd_high), ignoring errors."); #define OS_CLOSERANGE_METHODDEF \ - {"closerange", (PyCFunction)(void(*)(void))os_closerange, METH_FASTCALL, os_closerange__doc__}, + {"closerange", (PyCFunction)(void(*)(void))os_closerange, METH_FASTCALL, os_closerange__doc__}, static PyObject * os_closerange_impl(PyObject *module, int fd_low, int fd_high); @@ -4712,27 +4712,27 @@ os_closerange(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int fd_low; int fd_high; - if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd_low = _PyLong_AsInt(args[0]); - if (fd_low == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd_high = _PyLong_AsInt(args[1]); - if (fd_high == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd_low = _PyLong_AsInt(args[0]); + if (fd_low == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd_high = _PyLong_AsInt(args[1]); + if (fd_high == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_closerange_impl(module, fd_low, fd_high); exit: @@ -4758,15 +4758,15 @@ os_dup(PyObject *module, PyObject *arg) int fd; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_dup_impl(module, fd); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -4784,7 +4784,7 @@ PyDoc_STRVAR(os_dup2__doc__, "Duplicate file descriptor."); #define OS_DUP2_METHODDEF \ - {"dup2", (PyCFunction)(void(*)(void))os_dup2, METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, + {"dup2", (PyCFunction)(void(*)(void))os_dup2, METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, static int os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable); @@ -4794,44 +4794,44 @@ os_dup2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "fd2", "inheritable", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "dup2", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "dup2", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; int fd; int fd2; int inheritable = 1; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd2 = _PyLong_AsInt(args[1]); - if (fd2 == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - inheritable = PyObject_IsTrue(args[2]); - if (inheritable < 0) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd2 = _PyLong_AsInt(args[1]); + if (fd2 == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + inheritable = PyObject_IsTrue(args[2]); + if (inheritable < 0) { + goto exit; + } +skip_optional_pos: _return_value = os_dup2_impl(module, fd, fd2, inheritable); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -4858,7 +4858,7 @@ PyDoc_STRVAR(os_lockf__doc__, " The number of bytes to lock, starting at the current position."); #define OS_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)(void(*)(void))os_lockf, METH_FASTCALL, os_lockf__doc__}, + {"lockf", (PyCFunction)(void(*)(void))os_lockf, METH_FASTCALL, os_lockf__doc__}, static PyObject * os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length); @@ -4871,30 +4871,30 @@ os_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int command; Py_off_t length; - if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - command = _PyLong_AsInt(args[1]); - if (command == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[2], &length)) { - goto exit; - } + if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + command = _PyLong_AsInt(args[1]); + if (command == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[2], &length)) { + goto exit; + } return_value = os_lockf_impl(module, fd, command, length); exit: @@ -4913,7 +4913,7 @@ PyDoc_STRVAR(os_lseek__doc__, "relative to the beginning of the file."); #define OS_LSEEK_METHODDEF \ - {"lseek", (PyCFunction)(void(*)(void))os_lseek, METH_FASTCALL, os_lseek__doc__}, + {"lseek", (PyCFunction)(void(*)(void))os_lseek, METH_FASTCALL, os_lseek__doc__}, static Py_off_t os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how); @@ -4927,30 +4927,30 @@ os_lseek(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int how; Py_off_t _return_value; - if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[1], &position)) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - how = _PyLong_AsInt(args[2]); - if (how == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[1], &position)) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + how = _PyLong_AsInt(args[2]); + if (how == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_lseek_impl(module, fd, position, how); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -4968,7 +4968,7 @@ PyDoc_STRVAR(os_read__doc__, "Read from a file descriptor. Returns a bytes object."); #define OS_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))os_read, METH_FASTCALL, os_read__doc__}, + {"read", (PyCFunction)(void(*)(void))os_read, METH_FASTCALL, os_read__doc__}, static PyObject * os_read_impl(PyObject *module, int fd, Py_ssize_t length); @@ -4980,35 +4980,35 @@ os_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int fd; Py_ssize_t length; - if (!_PyArg_CheckPositional("read", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - length = ival; - } + if (!_PyArg_CheckPositional("read", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } return_value = os_read_impl(module, fd, length); exit: @@ -5032,7 +5032,7 @@ PyDoc_STRVAR(os_readv__doc__, "which may be less than the total capacity of all the buffers."); #define OS_READV_METHODDEF \ - {"readv", (PyCFunction)(void(*)(void))os_readv, METH_FASTCALL, os_readv__doc__}, + {"readv", (PyCFunction)(void(*)(void))os_readv, METH_FASTCALL, os_readv__doc__}, static Py_ssize_t os_readv_impl(PyObject *module, int fd, PyObject *buffers); @@ -5045,19 +5045,19 @@ os_readv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *buffers; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) { goto exit; } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - buffers = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + buffers = args[1]; _return_value = os_readv_impl(module, fd, buffers); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5082,51 +5082,51 @@ PyDoc_STRVAR(os_pread__doc__, "the beginning of the file. The file offset remains unchanged."); #define OS_PREAD_METHODDEF \ - {"pread", (PyCFunction)(void(*)(void))os_pread, METH_FASTCALL, os_pread__doc__}, + {"pread", (PyCFunction)(void(*)(void))os_pread, METH_FASTCALL, os_pread__doc__}, static PyObject * -os_pread_impl(PyObject *module, int fd, Py_ssize_t length, Py_off_t offset); +os_pread_impl(PyObject *module, int fd, Py_ssize_t length, Py_off_t offset); static PyObject * os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int fd; - Py_ssize_t length; + Py_ssize_t length; Py_off_t offset; - if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - length = ival; - } - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } + if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } return_value = os_pread_impl(module, fd, length, offset); exit: @@ -5158,7 +5158,7 @@ PyDoc_STRVAR(os_preadv__doc__, "Using non-zero flags requires Linux 4.6 or newer."); #define OS_PREADV_METHODDEF \ - {"preadv", (PyCFunction)(void(*)(void))os_preadv, METH_FASTCALL, os_preadv__doc__}, + {"preadv", (PyCFunction)(void(*)(void))os_preadv, METH_FASTCALL, os_preadv__doc__}, static Py_ssize_t os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, @@ -5174,35 +5174,35 @@ os_preadv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int flags = 0; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - buffers = args[1]; - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[3]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + buffers = args[1]; + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: _return_value = os_preadv_impl(module, fd, buffers, offset, flags); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5222,7 +5222,7 @@ PyDoc_STRVAR(os_write__doc__, "Write a bytes object to a file descriptor."); #define OS_WRITE_METHODDEF \ - {"write", (PyCFunction)(void(*)(void))os_write, METH_FASTCALL, os_write__doc__}, + {"write", (PyCFunction)(void(*)(void))os_write, METH_FASTCALL, os_write__doc__}, static Py_ssize_t os_write_impl(PyObject *module, int fd, Py_buffer *data); @@ -5235,25 +5235,25 @@ os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("write", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("write", "argument 2", "contiguous buffer", args[1]); - goto exit; - } + if (!_PyArg_CheckPositional("write", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("write", "argument 2", "contiguous buffer", args[1]); + goto exit; + } _return_value = os_write_impl(module, fd, &data); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5269,343 +5269,343 @@ exit: return return_value; } -#if defined(HAVE_SENDFILE) && defined(__APPLE__) - -PyDoc_STRVAR(os_sendfile__doc__, -"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" -" trailers=(), flags=0)\n" -"--\n" -"\n" -"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); - -#define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, - -static PyObject * -os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, - Py_off_t sbytes, PyObject *headers, PyObject *trailers, - int flags); - -static PyObject * -os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; - PyObject *argsbuf[7]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; - int out_fd; - int in_fd; - Py_off_t offset; - Py_off_t sbytes; - PyObject *headers = NULL; - PyObject *trailers = NULL; - int flags = 0; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - out_fd = _PyLong_AsInt(args[0]); - if (out_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - in_fd = _PyLong_AsInt(args[1]); - if (in_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } - if (!Py_off_t_converter(args[3], &sbytes)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[4]) { - headers = args[4]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[5]) { - trailers = args[5]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[6]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = os_sendfile_impl(module, out_fd, in_fd, offset, sbytes, headers, trailers, flags); - -exit: - return return_value; -} - -#endif /* defined(HAVE_SENDFILE) && defined(__APPLE__) */ - -#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) - -PyDoc_STRVAR(os_sendfile__doc__, -"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" -" trailers=(), flags=0)\n" -"--\n" -"\n" -"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); - -#define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, - -static PyObject * -os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, - Py_ssize_t count, PyObject *headers, PyObject *trailers, - int flags); - -static PyObject * -os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; - PyObject *argsbuf[7]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; - int out_fd; - int in_fd; - Py_off_t offset; - Py_ssize_t count; - PyObject *headers = NULL; - PyObject *trailers = NULL; - int flags = 0; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - out_fd = _PyLong_AsInt(args[0]); - if (out_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - in_fd = _PyLong_AsInt(args[1]); - if (in_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[3]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - count = ival; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[4]) { - headers = args[4]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[5]) { - trailers = args[5]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[6]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = os_sendfile_impl(module, out_fd, in_fd, offset, count, headers, trailers, flags); - -exit: - return return_value; -} - -#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) */ - -#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) - -PyDoc_STRVAR(os_sendfile__doc__, -"sendfile($module, /, out_fd, in_fd, offset, count)\n" -"--\n" -"\n" -"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); - -#define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, - -static PyObject * -os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, - Py_ssize_t count); - -static PyObject * -os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; - PyObject *argsbuf[4]; - int out_fd; - int in_fd; - PyObject *offobj; - Py_ssize_t count; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 4, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - out_fd = _PyLong_AsInt(args[0]); - if (out_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - in_fd = _PyLong_AsInt(args[1]); - if (in_fd == -1 && PyErr_Occurred()) { - goto exit; - } - offobj = args[2]; - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[3]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - count = ival; - } - return_value = os_sendfile_impl(module, out_fd, in_fd, offobj, count); - -exit: - return return_value; -} - -#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) */ - -#if defined(__APPLE__) - -PyDoc_STRVAR(os__fcopyfile__doc__, -"_fcopyfile($module, in_fd, out_fd, flags, /)\n" -"--\n" -"\n" -"Efficiently copy content or metadata of 2 regular file descriptors (macOS)."); - -#define OS__FCOPYFILE_METHODDEF \ - {"_fcopyfile", (PyCFunction)(void(*)(void))os__fcopyfile, METH_FASTCALL, os__fcopyfile__doc__}, - -static PyObject * -os__fcopyfile_impl(PyObject *module, int in_fd, int out_fd, int flags); - -static PyObject * -os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int in_fd; - int out_fd; - int flags; - - if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - in_fd = _PyLong_AsInt(args[0]); - if (in_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - out_fd = _PyLong_AsInt(args[1]); - if (out_fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[2]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = os__fcopyfile_impl(module, in_fd, out_fd, flags); - -exit: - return return_value; -} - -#endif /* defined(__APPLE__) */ - +#if defined(HAVE_SENDFILE) && defined(__APPLE__) + +PyDoc_STRVAR(os_sendfile__doc__, +"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" +" trailers=(), flags=0)\n" +"--\n" +"\n" +"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); + +#define OS_SENDFILE_METHODDEF \ + {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + +static PyObject * +os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, + Py_off_t sbytes, PyObject *headers, PyObject *trailers, + int flags); + +static PyObject * +os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; + PyObject *argsbuf[7]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; + int out_fd; + int in_fd; + Py_off_t offset; + Py_off_t sbytes; + PyObject *headers = NULL; + PyObject *trailers = NULL; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + out_fd = _PyLong_AsInt(args[0]); + if (out_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + in_fd = _PyLong_AsInt(args[1]); + if (in_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } + if (!Py_off_t_converter(args[3], &sbytes)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[4]) { + headers = args[4]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + trailers = args[5]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[6]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = os_sendfile_impl(module, out_fd, in_fd, offset, sbytes, headers, trailers, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SENDFILE) && defined(__APPLE__) */ + +#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) + +PyDoc_STRVAR(os_sendfile__doc__, +"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" +" trailers=(), flags=0)\n" +"--\n" +"\n" +"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); + +#define OS_SENDFILE_METHODDEF \ + {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + +static PyObject * +os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, + Py_ssize_t count, PyObject *headers, PyObject *trailers, + int flags); + +static PyObject * +os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; + PyObject *argsbuf[7]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; + int out_fd; + int in_fd; + Py_off_t offset; + Py_ssize_t count; + PyObject *headers = NULL; + PyObject *trailers = NULL; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + out_fd = _PyLong_AsInt(args[0]); + if (out_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + in_fd = _PyLong_AsInt(args[1]); + if (in_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[3]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[4]) { + headers = args[4]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + trailers = args[5]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[6]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = os_sendfile_impl(module, out_fd, in_fd, offset, count, headers, trailers, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) */ + +#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) + +PyDoc_STRVAR(os_sendfile__doc__, +"sendfile($module, /, out_fd, in_fd, offset, count)\n" +"--\n" +"\n" +"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); + +#define OS_SENDFILE_METHODDEF \ + {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + +static PyObject * +os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, + Py_ssize_t count); + +static PyObject * +os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; + PyObject *argsbuf[4]; + int out_fd; + int in_fd; + PyObject *offobj; + Py_ssize_t count; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 4, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + out_fd = _PyLong_AsInt(args[0]); + if (out_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + in_fd = _PyLong_AsInt(args[1]); + if (in_fd == -1 && PyErr_Occurred()) { + goto exit; + } + offobj = args[2]; + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[3]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } + return_value = os_sendfile_impl(module, out_fd, in_fd, offobj, count); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) */ + +#if defined(__APPLE__) + +PyDoc_STRVAR(os__fcopyfile__doc__, +"_fcopyfile($module, in_fd, out_fd, flags, /)\n" +"--\n" +"\n" +"Efficiently copy content or metadata of 2 regular file descriptors (macOS)."); + +#define OS__FCOPYFILE_METHODDEF \ + {"_fcopyfile", (PyCFunction)(void(*)(void))os__fcopyfile, METH_FASTCALL, os__fcopyfile__doc__}, + +static PyObject * +os__fcopyfile_impl(PyObject *module, int in_fd, int out_fd, int flags); + +static PyObject * +os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int in_fd; + int out_fd; + int flags; + + if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + in_fd = _PyLong_AsInt(args[0]); + if (in_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + out_fd = _PyLong_AsInt(args[1]); + if (out_fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = os__fcopyfile_impl(module, in_fd, out_fd, flags); + +exit: + return return_value; +} + +#endif /* defined(__APPLE__) */ + PyDoc_STRVAR(os_fstat__doc__, "fstat($module, /, fd)\n" "--\n" @@ -5616,7 +5616,7 @@ PyDoc_STRVAR(os_fstat__doc__, "Equivalent to os.stat(fd)."); #define OS_FSTAT_METHODDEF \ - {"fstat", (PyCFunction)(void(*)(void))os_fstat, METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, + {"fstat", (PyCFunction)(void(*)(void))os_fstat, METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, static PyObject * os_fstat_impl(PyObject *module, int fd); @@ -5626,23 +5626,23 @@ os_fstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fstat", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "fstat", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_fstat_impl(module, fd); exit: @@ -5671,15 +5671,15 @@ os_isatty(PyObject *module, PyObject *arg) int fd; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_isatty_impl(module, fd); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5741,15 +5741,15 @@ os_pipe2(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int flags; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(arg); - if (flags == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + flags = _PyLong_AsInt(arg); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_pipe2_impl(module, flags); exit: @@ -5770,7 +5770,7 @@ PyDoc_STRVAR(os_writev__doc__, "buffers must be a sequence of bytes-like objects."); #define OS_WRITEV_METHODDEF \ - {"writev", (PyCFunction)(void(*)(void))os_writev, METH_FASTCALL, os_writev__doc__}, + {"writev", (PyCFunction)(void(*)(void))os_writev, METH_FASTCALL, os_writev__doc__}, static Py_ssize_t os_writev_impl(PyObject *module, int fd, PyObject *buffers); @@ -5783,19 +5783,19 @@ os_writev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *buffers; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) { goto exit; } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - buffers = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + buffers = args[1]; _return_value = os_writev_impl(module, fd, buffers); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5821,7 +5821,7 @@ PyDoc_STRVAR(os_pwrite__doc__, "current file offset."); #define OS_PWRITE_METHODDEF \ - {"pwrite", (PyCFunction)(void(*)(void))os_pwrite, METH_FASTCALL, os_pwrite__doc__}, + {"pwrite", (PyCFunction)(void(*)(void))os_pwrite, METH_FASTCALL, os_pwrite__doc__}, static Py_ssize_t os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset); @@ -5835,28 +5835,28 @@ os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_off_t offset; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("pwrite", "argument 2", "contiguous buffer", args[1]); - goto exit; - } - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } + if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("pwrite", "argument 2", "contiguous buffer", args[1]); + goto exit; + } + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } _return_value = os_pwrite_impl(module, fd, &buffer, offset); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5897,7 +5897,7 @@ PyDoc_STRVAR(os_pwritev__doc__, "Using non-zero flags requires Linux 4.7 or newer."); #define OS_PWRITEV_METHODDEF \ - {"pwritev", (PyCFunction)(void(*)(void))os_pwritev, METH_FASTCALL, os_pwritev__doc__}, + {"pwritev", (PyCFunction)(void(*)(void))os_pwritev, METH_FASTCALL, os_pwritev__doc__}, static Py_ssize_t os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, @@ -5913,35 +5913,35 @@ os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int flags = 0; Py_ssize_t _return_value; - if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - buffers = args[1]; - if (!Py_off_t_converter(args[2], &offset)) { - goto exit; - } - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[3]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + buffers = args[1]; + if (!Py_off_t_converter(args[2], &offset)) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: _return_value = os_pwritev_impl(module, fd, buffers, offset, flags); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -5954,108 +5954,108 @@ exit: #endif /* (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) */ -#if defined(HAVE_COPY_FILE_RANGE) - -PyDoc_STRVAR(os_copy_file_range__doc__, -"copy_file_range($module, /, src, dst, count, offset_src=None,\n" -" offset_dst=None)\n" -"--\n" -"\n" -"Copy count bytes from one file descriptor to another.\n" -"\n" -" src\n" -" Source file descriptor.\n" -" dst\n" -" Destination file descriptor.\n" -" count\n" -" Number of bytes to copy.\n" -" offset_src\n" -" Starting offset in src.\n" -" offset_dst\n" -" Starting offset in dst.\n" -"\n" -"If offset_src is None, then src is read from the current position;\n" -"respectively for offset_dst."); - -#define OS_COPY_FILE_RANGE_METHODDEF \ - {"copy_file_range", (PyCFunction)(void(*)(void))os_copy_file_range, METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, - -static PyObject * -os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, - PyObject *offset_src, PyObject *offset_dst); - -static PyObject * -os_copy_file_range(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "copy_file_range", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; - int src; - int dst; - Py_ssize_t count; - PyObject *offset_src = Py_None; - PyObject *offset_dst = Py_None; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 5, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - src = _PyLong_AsInt(args[0]); - if (src == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - dst = _PyLong_AsInt(args[1]); - if (dst == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[2]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - count = ival; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[3]) { - offset_src = args[3]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - offset_dst = args[4]; -skip_optional_pos: - return_value = os_copy_file_range_impl(module, src, dst, count, offset_src, offset_dst); - -exit: - return return_value; -} - -#endif /* defined(HAVE_COPY_FILE_RANGE) */ - +#if defined(HAVE_COPY_FILE_RANGE) + +PyDoc_STRVAR(os_copy_file_range__doc__, +"copy_file_range($module, /, src, dst, count, offset_src=None,\n" +" offset_dst=None)\n" +"--\n" +"\n" +"Copy count bytes from one file descriptor to another.\n" +"\n" +" src\n" +" Source file descriptor.\n" +" dst\n" +" Destination file descriptor.\n" +" count\n" +" Number of bytes to copy.\n" +" offset_src\n" +" Starting offset in src.\n" +" offset_dst\n" +" Starting offset in dst.\n" +"\n" +"If offset_src is None, then src is read from the current position;\n" +"respectively for offset_dst."); + +#define OS_COPY_FILE_RANGE_METHODDEF \ + {"copy_file_range", (PyCFunction)(void(*)(void))os_copy_file_range, METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, + +static PyObject * +os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, + PyObject *offset_src, PyObject *offset_dst); + +static PyObject * +os_copy_file_range(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "copy_file_range", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + int src; + int dst; + Py_ssize_t count; + PyObject *offset_src = Py_None; + PyObject *offset_dst = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 5, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + src = _PyLong_AsInt(args[0]); + if (src == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + dst = _PyLong_AsInt(args[1]); + if (dst == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + offset_src = args[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + offset_dst = args[4]; +skip_optional_pos: + return_value = os_copy_file_range_impl(module, src, dst, count, offset_src, offset_dst); + +exit: + return return_value; +} + +#endif /* defined(HAVE_COPY_FILE_RANGE) */ + #if defined(HAVE_MKFIFO) PyDoc_STRVAR(os_mkfifo__doc__, @@ -6070,7 +6070,7 @@ PyDoc_STRVAR(os_mkfifo__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKFIFO_METHODDEF \ - {"mkfifo", (PyCFunction)(void(*)(void))os_mkfifo, METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, + {"mkfifo", (PyCFunction)(void(*)(void))os_mkfifo, METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, static PyObject * os_mkfifo_impl(PyObject *module, path_t *path, int mode, int dir_fd); @@ -6080,45 +6080,45 @@ os_mkfifo(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "mkfifo", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "mkfifo", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0); int mode = 438; int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!MKFIFOAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKFIFOAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_mkfifo_impl(module, &path, mode, dir_fd); exit: @@ -6151,7 +6151,7 @@ PyDoc_STRVAR(os_mknod__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKNOD_METHODDEF \ - {"mknod", (PyCFunction)(void(*)(void))os_mknod, METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, + {"mknod", (PyCFunction)(void(*)(void))os_mknod, METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, static PyObject * os_mknod_impl(PyObject *module, path_t *path, int mode, dev_t device, @@ -6162,54 +6162,54 @@ os_mknod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "device", "dir_fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "mknod", 0}; - PyObject *argsbuf[4]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "mknod", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0); int mode = 384; dev_t device = 0; int dir_fd = DEFAULT_DIR_FD; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[2]) { - if (!_Py_Dev_Converter(args[2], &device)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - if (!MKNODAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (!_Py_Dev_Converter(args[2], &device)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKNODAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_mknod_impl(module, &path, mode, device, dir_fd); exit: @@ -6242,7 +6242,7 @@ os_major(PyObject *module, PyObject *arg) dev_t device; unsigned int _return_value; - if (!_Py_Dev_Converter(arg, &device)) { + if (!_Py_Dev_Converter(arg, &device)) { goto exit; } _return_value = os_major_impl(module, device); @@ -6278,7 +6278,7 @@ os_minor(PyObject *module, PyObject *arg) dev_t device; unsigned int _return_value; - if (!_Py_Dev_Converter(arg, &device)) { + if (!_Py_Dev_Converter(arg, &device)) { goto exit; } _return_value = os_minor_impl(module, device); @@ -6302,7 +6302,7 @@ PyDoc_STRVAR(os_makedev__doc__, "Composes a raw device number from the major and minor device numbers."); #define OS_MAKEDEV_METHODDEF \ - {"makedev", (PyCFunction)(void(*)(void))os_makedev, METH_FASTCALL, os_makedev__doc__}, + {"makedev", (PyCFunction)(void(*)(void))os_makedev, METH_FASTCALL, os_makedev__doc__}, static dev_t os_makedev_impl(PyObject *module, int major, int minor); @@ -6315,27 +6315,27 @@ os_makedev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int minor; dev_t _return_value; - if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - major = _PyLong_AsInt(args[0]); - if (major == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - minor = _PyLong_AsInt(args[1]); - if (minor == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + major = _PyLong_AsInt(args[0]); + if (major == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + minor = _PyLong_AsInt(args[1]); + if (minor == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_makedev_impl(module, major, minor); if ((_return_value == (dev_t)-1) && PyErr_Occurred()) { goto exit; @@ -6357,7 +6357,7 @@ PyDoc_STRVAR(os_ftruncate__doc__, "Truncate a file, specified by file descriptor, to a specific length."); #define OS_FTRUNCATE_METHODDEF \ - {"ftruncate", (PyCFunction)(void(*)(void))os_ftruncate, METH_FASTCALL, os_ftruncate__doc__}, + {"ftruncate", (PyCFunction)(void(*)(void))os_ftruncate, METH_FASTCALL, os_ftruncate__doc__}, static PyObject * os_ftruncate_impl(PyObject *module, int fd, Py_off_t length); @@ -6369,21 +6369,21 @@ os_ftruncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int fd; Py_off_t length; - if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[1], &length)) { - goto exit; - } + if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[1], &length)) { + goto exit; + } return_value = os_ftruncate_impl(module, fd, length); exit: @@ -6404,7 +6404,7 @@ PyDoc_STRVAR(os_truncate__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))os_truncate, METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))os_truncate, METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, static PyObject * os_truncate_impl(PyObject *module, path_t *path, Py_off_t length); @@ -6414,21 +6414,21 @@ os_truncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "truncate", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "truncate", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); Py_off_t length; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!Py_off_t_converter(args[1], &length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!Py_off_t_converter(args[1], &length)) { + goto exit; + } return_value = os_truncate_impl(module, &path, length); exit: @@ -6452,7 +6452,7 @@ PyDoc_STRVAR(os_posix_fallocate__doc__, "starting at offset bytes from the beginning and continuing for length bytes."); #define OS_POSIX_FALLOCATE_METHODDEF \ - {"posix_fallocate", (PyCFunction)(void(*)(void))os_posix_fallocate, METH_FASTCALL, os_posix_fallocate__doc__}, + {"posix_fallocate", (PyCFunction)(void(*)(void))os_posix_fallocate, METH_FASTCALL, os_posix_fallocate__doc__}, static PyObject * os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset, @@ -6466,24 +6466,24 @@ os_posix_fallocate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_off_t offset; Py_off_t length; - if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[1], &offset)) { - goto exit; - } - if (!Py_off_t_converter(args[2], &length)) { - goto exit; - } + if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[1], &offset)) { + goto exit; + } + if (!Py_off_t_converter(args[2], &length)) { + goto exit; + } return_value = os_posix_fallocate_impl(module, fd, offset, length); exit: @@ -6509,7 +6509,7 @@ PyDoc_STRVAR(os_posix_fadvise__doc__, "POSIX_FADV_DONTNEED."); #define OS_POSIX_FADVISE_METHODDEF \ - {"posix_fadvise", (PyCFunction)(void(*)(void))os_posix_fadvise, METH_FASTCALL, os_posix_fadvise__doc__}, + {"posix_fadvise", (PyCFunction)(void(*)(void))os_posix_fadvise, METH_FASTCALL, os_posix_fadvise__doc__}, static PyObject * os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset, @@ -6524,33 +6524,33 @@ os_posix_fadvise(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_off_t length; int advice; - if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!Py_off_t_converter(args[1], &offset)) { - goto exit; - } - if (!Py_off_t_converter(args[2], &length)) { - goto exit; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - advice = _PyLong_AsInt(args[3]); - if (advice == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!Py_off_t_converter(args[1], &offset)) { + goto exit; + } + if (!Py_off_t_converter(args[2], &length)) { + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + advice = _PyLong_AsInt(args[3]); + if (advice == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); exit: @@ -6559,7 +6559,7 @@ exit: #endif /* (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) */ -#if defined(MS_WINDOWS) +#if defined(MS_WINDOWS) PyDoc_STRVAR(os_putenv__doc__, "putenv($module, name, value, /)\n" @@ -6568,7 +6568,7 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, + {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); @@ -6580,34 +6580,34 @@ os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *name; PyObject *value; - if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("putenv", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - name = args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("putenv", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - value = args[1]; + if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("putenv", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + name = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("putenv", "argument 2", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + value = args[1]; return_value = os_putenv_impl(module, name, value); exit: return return_value; } -#endif /* defined(MS_WINDOWS) */ +#endif /* defined(MS_WINDOWS) */ -#if !defined(MS_WINDOWS) +#if !defined(MS_WINDOWS) PyDoc_STRVAR(os_putenv__doc__, "putenv($module, name, value, /)\n" @@ -6616,7 +6616,7 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, + {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); @@ -6628,15 +6628,15 @@ os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *name = NULL; PyObject *value = NULL; - if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_FSConverter(args[0], &name)) { - goto exit; - } - if (!PyUnicode_FSConverter(args[1], &value)) { + if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { goto exit; } + if (!PyUnicode_FSConverter(args[0], &name)) { + goto exit; + } + if (!PyUnicode_FSConverter(args[1], &value)) { + goto exit; + } return_value = os_putenv_impl(module, name, value); exit: @@ -6648,45 +6648,9 @@ exit: return return_value; } -#endif /* !defined(MS_WINDOWS) */ +#endif /* !defined(MS_WINDOWS) */ -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(os_unsetenv__doc__, -"unsetenv($module, name, /)\n" -"--\n" -"\n" -"Delete an environment variable."); - -#define OS_UNSETENV_METHODDEF \ - {"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, - -static PyObject * -os_unsetenv_impl(PyObject *module, PyObject *name); - -static PyObject * -os_unsetenv(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - PyObject *name; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("unsetenv", "argument", "str", arg); - goto exit; - } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - name = arg; - return_value = os_unsetenv_impl(module, name); - -exit: - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - -#if !defined(MS_WINDOWS) +#if defined(MS_WINDOWS) PyDoc_STRVAR(os_unsetenv__doc__, "unsetenv($module, name, /)\n" @@ -6704,9 +6668,45 @@ static PyObject * os_unsetenv(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; + PyObject *name; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("unsetenv", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + name = arg; + return_value = os_unsetenv_impl(module, name); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#if !defined(MS_WINDOWS) + +PyDoc_STRVAR(os_unsetenv__doc__, +"unsetenv($module, name, /)\n" +"--\n" +"\n" +"Delete an environment variable."); + +#define OS_UNSETENV_METHODDEF \ + {"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, + +static PyObject * +os_unsetenv_impl(PyObject *module, PyObject *name); + +static PyObject * +os_unsetenv(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; PyObject *name = NULL; - if (!PyUnicode_FSConverter(arg, &name)) { + if (!PyUnicode_FSConverter(arg, &name)) { goto exit; } return_value = os_unsetenv_impl(module, name); @@ -6718,7 +6718,7 @@ exit: return return_value; } -#endif /* !defined(MS_WINDOWS) */ +#endif /* !defined(MS_WINDOWS) */ PyDoc_STRVAR(os_strerror__doc__, "strerror($module, code, /)\n" @@ -6738,15 +6738,15 @@ os_strerror(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int code; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = _PyLong_AsInt(arg); - if (code == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + code = _PyLong_AsInt(arg); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_strerror_impl(module, code); exit: @@ -6774,15 +6774,15 @@ os_WCOREDUMP(PyObject *module, PyObject *arg) int status; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(arg); - if (status == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + status = _PyLong_AsInt(arg); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WCOREDUMP_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6807,7 +6807,7 @@ PyDoc_STRVAR(os_WIFCONTINUED__doc__, "job control stop."); #define OS_WIFCONTINUED_METHODDEF \ - {"WIFCONTINUED", (PyCFunction)(void(*)(void))os_WIFCONTINUED, METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, + {"WIFCONTINUED", (PyCFunction)(void(*)(void))os_WIFCONTINUED, METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, static int os_WIFCONTINUED_impl(PyObject *module, int status); @@ -6817,24 +6817,24 @@ os_WIFCONTINUED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WIFCONTINUED", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFCONTINUED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WIFCONTINUED_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6856,7 +6856,7 @@ PyDoc_STRVAR(os_WIFSTOPPED__doc__, "Return True if the process returning status was stopped."); #define OS_WIFSTOPPED_METHODDEF \ - {"WIFSTOPPED", (PyCFunction)(void(*)(void))os_WIFSTOPPED, METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, + {"WIFSTOPPED", (PyCFunction)(void(*)(void))os_WIFSTOPPED, METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, static int os_WIFSTOPPED_impl(PyObject *module, int status); @@ -6866,24 +6866,24 @@ os_WIFSTOPPED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WIFSTOPPED", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFSTOPPED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WIFSTOPPED_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6905,7 +6905,7 @@ PyDoc_STRVAR(os_WIFSIGNALED__doc__, "Return True if the process returning status was terminated by a signal."); #define OS_WIFSIGNALED_METHODDEF \ - {"WIFSIGNALED", (PyCFunction)(void(*)(void))os_WIFSIGNALED, METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, + {"WIFSIGNALED", (PyCFunction)(void(*)(void))os_WIFSIGNALED, METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, static int os_WIFSIGNALED_impl(PyObject *module, int status); @@ -6915,24 +6915,24 @@ os_WIFSIGNALED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WIFSIGNALED", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFSIGNALED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WIFSIGNALED_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6954,7 +6954,7 @@ PyDoc_STRVAR(os_WIFEXITED__doc__, "Return True if the process returning status exited via the exit() system call."); #define OS_WIFEXITED_METHODDEF \ - {"WIFEXITED", (PyCFunction)(void(*)(void))os_WIFEXITED, METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, + {"WIFEXITED", (PyCFunction)(void(*)(void))os_WIFEXITED, METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, static int os_WIFEXITED_impl(PyObject *module, int status); @@ -6964,24 +6964,24 @@ os_WIFEXITED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WIFEXITED", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFEXITED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WIFEXITED_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7003,7 +7003,7 @@ PyDoc_STRVAR(os_WEXITSTATUS__doc__, "Return the process return code from status."); #define OS_WEXITSTATUS_METHODDEF \ - {"WEXITSTATUS", (PyCFunction)(void(*)(void))os_WEXITSTATUS, METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, + {"WEXITSTATUS", (PyCFunction)(void(*)(void))os_WEXITSTATUS, METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, static int os_WEXITSTATUS_impl(PyObject *module, int status); @@ -7013,24 +7013,24 @@ os_WEXITSTATUS(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WEXITSTATUS", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WEXITSTATUS", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WEXITSTATUS_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7052,7 +7052,7 @@ PyDoc_STRVAR(os_WTERMSIG__doc__, "Return the signal that terminated the process that provided the status value."); #define OS_WTERMSIG_METHODDEF \ - {"WTERMSIG", (PyCFunction)(void(*)(void))os_WTERMSIG, METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, + {"WTERMSIG", (PyCFunction)(void(*)(void))os_WTERMSIG, METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, static int os_WTERMSIG_impl(PyObject *module, int status); @@ -7062,24 +7062,24 @@ os_WTERMSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WTERMSIG", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WTERMSIG", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WTERMSIG_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7101,7 +7101,7 @@ PyDoc_STRVAR(os_WSTOPSIG__doc__, "Return the signal that stopped the process that provided the status value."); #define OS_WSTOPSIG_METHODDEF \ - {"WSTOPSIG", (PyCFunction)(void(*)(void))os_WSTOPSIG, METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, + {"WSTOPSIG", (PyCFunction)(void(*)(void))os_WSTOPSIG, METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, static int os_WSTOPSIG_impl(PyObject *module, int status); @@ -7111,24 +7111,24 @@ os_WSTOPSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "WSTOPSIG", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "WSTOPSIG", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - status = _PyLong_AsInt(args[0]); - if (status == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_WSTOPSIG_impl(module, status); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7163,15 +7163,15 @@ os_fstatvfs(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_fstatvfs_impl(module, fd); exit: @@ -7193,7 +7193,7 @@ PyDoc_STRVAR(os_statvfs__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_STATVFS_METHODDEF \ - {"statvfs", (PyCFunction)(void(*)(void))os_statvfs, METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, + {"statvfs", (PyCFunction)(void(*)(void))os_statvfs, METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, static PyObject * os_statvfs_impl(PyObject *module, path_t *path); @@ -7203,17 +7203,17 @@ os_statvfs(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "statvfs", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "statvfs", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } return_value = os_statvfs_impl(module, &path); exit: @@ -7234,7 +7234,7 @@ PyDoc_STRVAR(os__getdiskusage__doc__, "Return disk usage statistics about the given path as a (total, free) tuple."); #define OS__GETDISKUSAGE_METHODDEF \ - {"_getdiskusage", (PyCFunction)(void(*)(void))os__getdiskusage, METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, + {"_getdiskusage", (PyCFunction)(void(*)(void))os__getdiskusage, METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, static PyObject * os__getdiskusage_impl(PyObject *module, path_t *path); @@ -7244,17 +7244,17 @@ os__getdiskusage(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_getdiskusage", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "_getdiskusage", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("_getdiskusage", "path", 0, 0); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } return_value = os__getdiskusage_impl(module, &path); exit: @@ -7277,7 +7277,7 @@ PyDoc_STRVAR(os_fpathconf__doc__, "If there is no limit, return -1."); #define OS_FPATHCONF_METHODDEF \ - {"fpathconf", (PyCFunction)(void(*)(void))os_fpathconf, METH_FASTCALL, os_fpathconf__doc__}, + {"fpathconf", (PyCFunction)(void(*)(void))os_fpathconf, METH_FASTCALL, os_fpathconf__doc__}, static long os_fpathconf_impl(PyObject *module, int fd, int name); @@ -7290,21 +7290,21 @@ os_fpathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int name; long _return_value; - if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!conv_path_confname(args[1], &name)) { - goto exit; - } + if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!conv_path_confname(args[1], &name)) { + goto exit; + } _return_value = os_fpathconf_impl(module, fd, name); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7330,7 +7330,7 @@ PyDoc_STRVAR(os_pathconf__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_PATHCONF_METHODDEF \ - {"pathconf", (PyCFunction)(void(*)(void))os_pathconf, METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, + {"pathconf", (PyCFunction)(void(*)(void))os_pathconf, METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, static long os_pathconf_impl(PyObject *module, path_t *path, int name); @@ -7340,22 +7340,22 @@ os_pathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "name", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "pathconf", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "pathconf", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF); int name; long _return_value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!conv_path_confname(args[1], &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!conv_path_confname(args[1], &name)) { + goto exit; + } _return_value = os_pathconf_impl(module, &path, name); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -7391,7 +7391,7 @@ os_confstr(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int name; - if (!conv_confstr_confname(arg, &name)) { + if (!conv_confstr_confname(arg, &name)) { goto exit; } return_value = os_confstr_impl(module, name); @@ -7423,7 +7423,7 @@ os_sysconf(PyObject *module, PyObject *arg) int name; long _return_value; - if (!conv_sysconf_confname(arg, &name)) { + if (!conv_sysconf_confname(arg, &name)) { goto exit; } _return_value = os_sysconf_impl(module, name); @@ -7462,7 +7462,7 @@ os_abort(PyObject *module, PyObject *Py_UNUSED(ignored)) #if defined(MS_WINDOWS) PyDoc_STRVAR(os_startfile__doc__, -"startfile($module, /, filepath, operation=<unrepresentable>)\n" +"startfile($module, /, filepath, operation=<unrepresentable>)\n" "--\n" "\n" "Start a file with its associated application.\n" @@ -7483,7 +7483,7 @@ PyDoc_STRVAR(os_startfile__doc__, "the underlying Win32 ShellExecute function doesn\'t work if it is."); #define OS_STARTFILE_METHODDEF \ - {"startfile", (PyCFunction)(void(*)(void))os_startfile, METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, + {"startfile", (PyCFunction)(void(*)(void))os_startfile, METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, static PyObject * os_startfile_impl(PyObject *module, path_t *filepath, @@ -7549,7 +7549,7 @@ PyDoc_STRVAR(os_device_encoding__doc__, "If the device is not a terminal, return None."); #define OS_DEVICE_ENCODING_METHODDEF \ - {"device_encoding", (PyCFunction)(void(*)(void))os_device_encoding, METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, + {"device_encoding", (PyCFunction)(void(*)(void))os_device_encoding, METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, static PyObject * os_device_encoding_impl(PyObject *module, int fd); @@ -7559,23 +7559,23 @@ os_device_encoding(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "device_encoding", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "device_encoding", 0}; + PyObject *argsbuf[1]; int fd; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_device_encoding_impl(module, fd); exit: @@ -7591,7 +7591,7 @@ PyDoc_STRVAR(os_setresuid__doc__, "Set the current process\'s real, effective, and saved user ids."); #define OS_SETRESUID_METHODDEF \ - {"setresuid", (PyCFunction)(void(*)(void))os_setresuid, METH_FASTCALL, os_setresuid__doc__}, + {"setresuid", (PyCFunction)(void(*)(void))os_setresuid, METH_FASTCALL, os_setresuid__doc__}, static PyObject * os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid); @@ -7604,18 +7604,18 @@ os_setresuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) uid_t euid; uid_t suid; - if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) { - goto exit; - } - if (!_Py_Uid_Converter(args[0], &ruid)) { - goto exit; - } - if (!_Py_Uid_Converter(args[1], &euid)) { - goto exit; - } - if (!_Py_Uid_Converter(args[2], &suid)) { + if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) { goto exit; } + if (!_Py_Uid_Converter(args[0], &ruid)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &euid)) { + goto exit; + } + if (!_Py_Uid_Converter(args[2], &suid)) { + goto exit; + } return_value = os_setresuid_impl(module, ruid, euid, suid); exit: @@ -7633,7 +7633,7 @@ PyDoc_STRVAR(os_setresgid__doc__, "Set the current process\'s real, effective, and saved group ids."); #define OS_SETRESGID_METHODDEF \ - {"setresgid", (PyCFunction)(void(*)(void))os_setresgid, METH_FASTCALL, os_setresgid__doc__}, + {"setresgid", (PyCFunction)(void(*)(void))os_setresgid, METH_FASTCALL, os_setresgid__doc__}, static PyObject * os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid); @@ -7646,18 +7646,18 @@ os_setresgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) gid_t egid; gid_t sgid; - if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) { - goto exit; - } - if (!_Py_Gid_Converter(args[0], &rgid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[1], &egid)) { - goto exit; - } - if (!_Py_Gid_Converter(args[2], &sgid)) { + if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) { goto exit; } + if (!_Py_Gid_Converter(args[0], &rgid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[1], &egid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &sgid)) { + goto exit; + } return_value = os_setresgid_impl(module, rgid, egid, sgid); exit: @@ -7724,7 +7724,7 @@ PyDoc_STRVAR(os_getxattr__doc__, " the link points to."); #define OS_GETXATTR_METHODDEF \ - {"getxattr", (PyCFunction)(void(*)(void))os_getxattr, METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, + {"getxattr", (PyCFunction)(void(*)(void))os_getxattr, METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, static PyObject * os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7735,31 +7735,31 @@ os_getxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "getxattr", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "getxattr", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!path_converter(args[1], &attribute)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - follow_symlinks = PyObject_IsTrue(args[2]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); exit: @@ -7788,7 +7788,7 @@ PyDoc_STRVAR(os_setxattr__doc__, " the link points to."); #define OS_SETXATTR_METHODDEF \ - {"setxattr", (PyCFunction)(void(*)(void))os_setxattr, METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, + {"setxattr", (PyCFunction)(void(*)(void))os_setxattr, METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, static PyObject * os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7799,58 +7799,58 @@ os_setxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "setxattr", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + static _PyArg_Parser _parser = {NULL, _keywords, "setxattr", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0); Py_buffer value = {NULL, NULL}; int flags = 0; int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!path_converter(args[1], &attribute)) { - goto exit; - } - if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&value, 'C')) { - _PyArg_BadArgument("setxattr", "argument 'value'", "contiguous buffer", args[2]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[3]) { - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[3]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - follow_symlinks = PyObject_IsTrue(args[4]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { + goto exit; + } + if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&value, 'C')) { + _PyArg_BadArgument("setxattr", "argument 'value'", "contiguous buffer", args[2]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); exit: @@ -7882,7 +7882,7 @@ PyDoc_STRVAR(os_removexattr__doc__, " the link points to."); #define OS_REMOVEXATTR_METHODDEF \ - {"removexattr", (PyCFunction)(void(*)(void))os_removexattr, METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, + {"removexattr", (PyCFunction)(void(*)(void))os_removexattr, METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, static PyObject * os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7893,31 +7893,31 @@ os_removexattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "removexattr", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "removexattr", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!path_converter(args[1], &attribute)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_kwonly; - } - follow_symlinks = PyObject_IsTrue(args[2]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); exit: @@ -7946,7 +7946,7 @@ PyDoc_STRVAR(os_listxattr__doc__, " the link points to."); #define OS_LISTXATTR_METHODDEF \ - {"listxattr", (PyCFunction)(void(*)(void))os_listxattr, METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, + {"listxattr", (PyCFunction)(void(*)(void))os_listxattr, METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, static PyObject * os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks); @@ -7956,36 +7956,36 @@ os_listxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "listxattr", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "listxattr", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); int follow_symlinks = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - if (!path_converter(args[0], &path)) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - follow_symlinks = PyObject_IsTrue(args[1]); - if (follow_symlinks < 0) { - goto exit; - } -skip_optional_kwonly: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[1]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_listxattr_impl(module, &path, follow_symlinks); exit: @@ -8015,140 +8015,140 @@ os_urandom(PyObject *module, PyObject *arg) PyObject *return_value = NULL; Py_ssize_t size; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(arg); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - size = ival; - } + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + size = ival; + } return_value = os_urandom_impl(module, size); exit: return return_value; } -#if defined(HAVE_MEMFD_CREATE) - -PyDoc_STRVAR(os_memfd_create__doc__, -"memfd_create($module, /, name, flags=MFD_CLOEXEC)\n" -"--\n" -"\n"); - -#define OS_MEMFD_CREATE_METHODDEF \ - {"memfd_create", (PyCFunction)(void(*)(void))os_memfd_create, METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, - -static PyObject * -os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags); - -static PyObject * -os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"name", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "memfd_create", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - PyObject *name = NULL; - unsigned int flags = MFD_CLOEXEC; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_FSConverter(args[0], &name)) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (flags == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = os_memfd_create_impl(module, name, flags); - -exit: - /* Cleanup for name */ - Py_XDECREF(name); - - return return_value; -} - -#endif /* defined(HAVE_MEMFD_CREATE) */ - -#if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) - -PyDoc_STRVAR(os_get_terminal_size__doc__, -"get_terminal_size($module, fd=<unrepresentable>, /)\n" -"--\n" -"\n" -"Return the size of the terminal window as (columns, lines).\n" -"\n" -"The optional argument fd (default standard output) specifies\n" -"which file descriptor should be queried.\n" -"\n" -"If the file descriptor is not connected to a terminal, an OSError\n" -"is thrown.\n" -"\n" -"This function will only be defined if an implementation is\n" -"available for this system.\n" -"\n" -"shutil.get_terminal_size is the high-level function which should\n" -"normally be used, os.get_terminal_size is the low-level implementation."); - -#define OS_GET_TERMINAL_SIZE_METHODDEF \ - {"get_terminal_size", (PyCFunction)(void(*)(void))os_get_terminal_size, METH_FASTCALL, os_get_terminal_size__doc__}, - -static PyObject * -os_get_terminal_size_impl(PyObject *module, int fd); - -static PyObject * -os_get_terminal_size(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd = fileno(stdout); - - if (!_PyArg_CheckPositional("get_terminal_size", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = os_get_terminal_size_impl(module, fd); - -exit: - return return_value; -} - -#endif /* (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) */ - +#if defined(HAVE_MEMFD_CREATE) + +PyDoc_STRVAR(os_memfd_create__doc__, +"memfd_create($module, /, name, flags=MFD_CLOEXEC)\n" +"--\n" +"\n"); + +#define OS_MEMFD_CREATE_METHODDEF \ + {"memfd_create", (PyCFunction)(void(*)(void))os_memfd_create, METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, + +static PyObject * +os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags); + +static PyObject * +os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"name", "flags", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "memfd_create", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *name = NULL; + unsigned int flags = MFD_CLOEXEC; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_FSConverter(args[0], &name)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (flags == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = os_memfd_create_impl(module, name, flags); + +exit: + /* Cleanup for name */ + Py_XDECREF(name); + + return return_value; +} + +#endif /* defined(HAVE_MEMFD_CREATE) */ + +#if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) + +PyDoc_STRVAR(os_get_terminal_size__doc__, +"get_terminal_size($module, fd=<unrepresentable>, /)\n" +"--\n" +"\n" +"Return the size of the terminal window as (columns, lines).\n" +"\n" +"The optional argument fd (default standard output) specifies\n" +"which file descriptor should be queried.\n" +"\n" +"If the file descriptor is not connected to a terminal, an OSError\n" +"is thrown.\n" +"\n" +"This function will only be defined if an implementation is\n" +"available for this system.\n" +"\n" +"shutil.get_terminal_size is the high-level function which should\n" +"normally be used, os.get_terminal_size is the low-level implementation."); + +#define OS_GET_TERMINAL_SIZE_METHODDEF \ + {"get_terminal_size", (PyCFunction)(void(*)(void))os_get_terminal_size, METH_FASTCALL, os_get_terminal_size__doc__}, + +static PyObject * +os_get_terminal_size_impl(PyObject *module, int fd); + +static PyObject * +os_get_terminal_size(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd = fileno(stdout); + + if (!_PyArg_CheckPositional("get_terminal_size", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = os_get_terminal_size_impl(module, fd); + +exit: + return return_value; +} + +#endif /* (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) */ + PyDoc_STRVAR(os_cpu_count__doc__, "cpu_count($module, /)\n" "--\n" @@ -8190,15 +8190,15 @@ os_get_inheritable(PyObject *module, PyObject *arg) int fd; int _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = os_get_inheritable_impl(module, fd); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -8216,7 +8216,7 @@ PyDoc_STRVAR(os_set_inheritable__doc__, "Set the inheritable flag of the specified file descriptor."); #define OS_SET_INHERITABLE_METHODDEF \ - {"set_inheritable", (PyCFunction)(void(*)(void))os_set_inheritable, METH_FASTCALL, os_set_inheritable__doc__}, + {"set_inheritable", (PyCFunction)(void(*)(void))os_set_inheritable, METH_FASTCALL, os_set_inheritable__doc__}, static PyObject * os_set_inheritable_impl(PyObject *module, int fd, int inheritable); @@ -8228,27 +8228,27 @@ os_set_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int fd; int inheritable; - if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - inheritable = _PyLong_AsInt(args[1]); - if (inheritable == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + inheritable = _PyLong_AsInt(args[1]); + if (inheritable == -1 && PyErr_Occurred()) { + goto exit; + } return_value = os_set_inheritable_impl(module, fd, inheritable); exit: @@ -8300,7 +8300,7 @@ PyDoc_STRVAR(os_set_handle_inheritable__doc__, "Set the inheritable flag of the specified handle."); #define OS_SET_HANDLE_INHERITABLE_METHODDEF \ - {"set_handle_inheritable", (PyCFunction)(void(*)(void))os_set_handle_inheritable, METH_FASTCALL, os_set_handle_inheritable__doc__}, + {"set_handle_inheritable", (PyCFunction)(void(*)(void))os_set_handle_inheritable, METH_FASTCALL, os_set_handle_inheritable__doc__}, static PyObject * os_set_handle_inheritable_impl(PyObject *module, intptr_t handle, @@ -8325,103 +8325,103 @@ exit: #endif /* defined(MS_WINDOWS) */ -#if !defined(MS_WINDOWS) - -PyDoc_STRVAR(os_get_blocking__doc__, -"get_blocking($module, fd, /)\n" -"--\n" -"\n" -"Get the blocking mode of the file descriptor.\n" -"\n" -"Return False if the O_NONBLOCK flag is set, True if the flag is cleared."); - -#define OS_GET_BLOCKING_METHODDEF \ - {"get_blocking", (PyCFunction)os_get_blocking, METH_O, os_get_blocking__doc__}, - -static int -os_get_blocking_impl(PyObject *module, int fd); - -static PyObject * -os_get_blocking(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - int _return_value; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = os_get_blocking_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - -#endif /* !defined(MS_WINDOWS) */ - -#if !defined(MS_WINDOWS) - -PyDoc_STRVAR(os_set_blocking__doc__, -"set_blocking($module, fd, blocking, /)\n" -"--\n" -"\n" -"Set the blocking mode of the specified file descriptor.\n" -"\n" -"Set the O_NONBLOCK flag if blocking is False,\n" -"clear the O_NONBLOCK flag otherwise."); - -#define OS_SET_BLOCKING_METHODDEF \ - {"set_blocking", (PyCFunction)(void(*)(void))os_set_blocking, METH_FASTCALL, os_set_blocking__doc__}, - -static PyObject * -os_set_blocking_impl(PyObject *module, int fd, int blocking); - -static PyObject * -os_set_blocking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - int blocking; - - if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - blocking = _PyLong_AsInt(args[1]); - if (blocking == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = os_set_blocking_impl(module, fd, blocking); - -exit: - return return_value; -} - -#endif /* !defined(MS_WINDOWS) */ - +#if !defined(MS_WINDOWS) + +PyDoc_STRVAR(os_get_blocking__doc__, +"get_blocking($module, fd, /)\n" +"--\n" +"\n" +"Get the blocking mode of the file descriptor.\n" +"\n" +"Return False if the O_NONBLOCK flag is set, True if the flag is cleared."); + +#define OS_GET_BLOCKING_METHODDEF \ + {"get_blocking", (PyCFunction)os_get_blocking, METH_O, os_get_blocking__doc__}, + +static int +os_get_blocking_impl(PyObject *module, int fd); + +static PyObject * +os_get_blocking(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + int _return_value; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + _return_value = os_get_blocking_impl(module, fd); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* !defined(MS_WINDOWS) */ + +#if !defined(MS_WINDOWS) + +PyDoc_STRVAR(os_set_blocking__doc__, +"set_blocking($module, fd, blocking, /)\n" +"--\n" +"\n" +"Set the blocking mode of the specified file descriptor.\n" +"\n" +"Set the O_NONBLOCK flag if blocking is False,\n" +"clear the O_NONBLOCK flag otherwise."); + +#define OS_SET_BLOCKING_METHODDEF \ + {"set_blocking", (PyCFunction)(void(*)(void))os_set_blocking, METH_FASTCALL, os_set_blocking__doc__}, + +static PyObject * +os_set_blocking_impl(PyObject *module, int fd, int blocking); + +static PyObject * +os_set_blocking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd; + int blocking; + + if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + blocking = _PyLong_AsInt(args[1]); + if (blocking == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = os_set_blocking_impl(module, fd, blocking); + +exit: + return return_value; +} + +#endif /* !defined(MS_WINDOWS) */ + PyDoc_STRVAR(os_DirEntry_is_symlink__doc__, "is_symlink($self, /)\n" "--\n" @@ -8429,24 +8429,24 @@ PyDoc_STRVAR(os_DirEntry_is_symlink__doc__, "Return True if the entry is a symbolic link; cached per entry."); #define OS_DIRENTRY_IS_SYMLINK_METHODDEF \ - {"is_symlink", (PyCFunction)(void(*)(void))os_DirEntry_is_symlink, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, + {"is_symlink", (PyCFunction)(void(*)(void))os_DirEntry_is_symlink, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, static int -os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class); +os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class); static PyObject * -os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":is_symlink", _keywords, 0}; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":is_symlink", _keywords, 0}; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - _return_value = os_DirEntry_is_symlink_impl(self, defining_class); + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + _return_value = os_DirEntry_is_symlink_impl(self, defining_class); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; } @@ -8463,25 +8463,25 @@ PyDoc_STRVAR(os_DirEntry_stat__doc__, "Return stat_result object for the entry; cached per entry."); #define OS_DIRENTRY_STAT_METHODDEF \ - {"stat", (PyCFunction)(void(*)(void))os_DirEntry_stat, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, + {"stat", (PyCFunction)(void(*)(void))os_DirEntry_stat, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, static PyObject * -os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class, - int follow_symlinks); +os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class, + int follow_symlinks); static PyObject * -os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0}; + static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0}; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &follow_symlinks)) { goto exit; } - return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks); + return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks); exit: return return_value; @@ -8494,26 +8494,26 @@ PyDoc_STRVAR(os_DirEntry_is_dir__doc__, "Return True if the entry is a directory; cached per entry."); #define OS_DIRENTRY_IS_DIR_METHODDEF \ - {"is_dir", (PyCFunction)(void(*)(void))os_DirEntry_is_dir, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, + {"is_dir", (PyCFunction)(void(*)(void))os_DirEntry_is_dir, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, static int -os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class, - int follow_symlinks); +os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class, + int follow_symlinks); static PyObject * -os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0}; + static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0}; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &follow_symlinks)) { goto exit; } - _return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks); + _return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; } @@ -8530,26 +8530,26 @@ PyDoc_STRVAR(os_DirEntry_is_file__doc__, "Return True if the entry is a file; cached per entry."); #define OS_DIRENTRY_IS_FILE_METHODDEF \ - {"is_file", (PyCFunction)(void(*)(void))os_DirEntry_is_file, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, + {"is_file", (PyCFunction)(void(*)(void))os_DirEntry_is_file, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, static int -os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class, - int follow_symlinks); +os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class, + int follow_symlinks); static PyObject * -os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0}; + static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0}; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &follow_symlinks)) { goto exit; } - _return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks); + _return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; } @@ -8608,7 +8608,7 @@ PyDoc_STRVAR(os_scandir__doc__, "If path is None, uses the path=\'.\'."); #define OS_SCANDIR_METHODDEF \ - {"scandir", (PyCFunction)(void(*)(void))os_scandir, METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, + {"scandir", (PyCFunction)(void(*)(void))os_scandir, METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, static PyObject * os_scandir_impl(PyObject *module, path_t *path); @@ -8618,22 +8618,22 @@ os_scandir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "scandir", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "scandir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("scandir", "path", 1, PATH_HAVE_FDOPENDIR); - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (!path_converter(args[0], &path)) { - goto exit; - } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (!path_converter(args[0], &path)) { + goto exit; + } +skip_optional_pos: return_value = os_scandir_impl(module, &path); exit: @@ -8654,7 +8654,7 @@ PyDoc_STRVAR(os_fspath__doc__, "types raise a TypeError."); #define OS_FSPATH_METHODDEF \ - {"fspath", (PyCFunction)(void(*)(void))os_fspath, METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, + {"fspath", (PyCFunction)(void(*)(void))os_fspath, METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, static PyObject * os_fspath_impl(PyObject *module, PyObject *path); @@ -8664,15 +8664,15 @@ os_fspath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fspath", 0}; - PyObject *argsbuf[1]; + static _PyArg_Parser _parser = {NULL, _keywords, "fspath", 0}; + PyObject *argsbuf[1]; PyObject *path; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - path = args[0]; + path = args[0]; return_value = os_fspath_impl(module, path); exit: @@ -8688,7 +8688,7 @@ PyDoc_STRVAR(os_getrandom__doc__, "Obtain a series of random bytes."); #define OS_GETRANDOM_METHODDEF \ - {"getrandom", (PyCFunction)(void(*)(void))os_getrandom, METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, + {"getrandom", (PyCFunction)(void(*)(void))os_getrandom, METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, static PyObject * os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags); @@ -8698,46 +8698,46 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"size", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "getrandom", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "getrandom", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_ssize_t size; int flags = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - size = ival; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + size = ival; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = os_getrandom_impl(module, size, flags); exit: @@ -8746,142 +8746,142 @@ exit: #endif /* defined(HAVE_GETRANDOM_SYSCALL) */ -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(os__add_dll_directory__doc__, -"_add_dll_directory($module, /, path)\n" -"--\n" -"\n" -"Add a path to the DLL search path.\n" -"\n" -"This search path is used when resolving dependencies for imported\n" -"extension modules (the module itself is resolved through sys.path),\n" -"and also by ctypes.\n" -"\n" -"Returns an opaque value that may be passed to os.remove_dll_directory\n" -"to remove this directory from the search path."); - -#define OS__ADD_DLL_DIRECTORY_METHODDEF \ - {"_add_dll_directory", (PyCFunction)(void(*)(void))os__add_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, - -static PyObject * -os__add_dll_directory_impl(PyObject *module, path_t *path); - -static PyObject * -os__add_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_add_dll_directory", 0}; - PyObject *argsbuf[1]; - path_t path = PATH_T_INITIALIZE("_add_dll_directory", "path", 0, 0); - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!path_converter(args[0], &path)) { - goto exit; - } - return_value = os__add_dll_directory_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(os__remove_dll_directory__doc__, -"_remove_dll_directory($module, /, cookie)\n" -"--\n" -"\n" -"Removes a path from the DLL search path.\n" -"\n" -"The parameter is an opaque value that was returned from\n" -"os.add_dll_directory. You can only remove directories that you added\n" -"yourself."); - -#define OS__REMOVE_DLL_DIRECTORY_METHODDEF \ - {"_remove_dll_directory", (PyCFunction)(void(*)(void))os__remove_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, - -static PyObject * -os__remove_dll_directory_impl(PyObject *module, PyObject *cookie); - -static PyObject * -os__remove_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"cookie", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_remove_dll_directory", 0}; - PyObject *argsbuf[1]; - PyObject *cookie; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - cookie = args[0]; - return_value = os__remove_dll_directory_impl(module, cookie); - -exit: - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - -#if (defined(WIFEXITED) || defined(MS_WINDOWS)) - -PyDoc_STRVAR(os_waitstatus_to_exitcode__doc__, -"waitstatus_to_exitcode($module, /, status)\n" -"--\n" -"\n" -"Convert a wait status to an exit code.\n" -"\n" -"On Unix:\n" -"\n" -"* If WIFEXITED(status) is true, return WEXITSTATUS(status).\n" -"* If WIFSIGNALED(status) is true, return -WTERMSIG(status).\n" -"* Otherwise, raise a ValueError.\n" -"\n" -"On Windows, return status shifted right by 8 bits.\n" -"\n" -"On Unix, if the process is being traced or if waitpid() was called with\n" -"WUNTRACED option, the caller must first check if WIFSTOPPED(status) is true.\n" -"This function must not be called if WIFSTOPPED(status) is true."); - -#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF \ - {"waitstatus_to_exitcode", (PyCFunction)(void(*)(void))os_waitstatus_to_exitcode, METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, - -static PyObject * -os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj); - -static PyObject * -os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "waitstatus_to_exitcode", 0}; - PyObject *argsbuf[1]; - PyObject *status_obj; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - status_obj = args[0]; - return_value = os_waitstatus_to_exitcode_impl(module, status_obj); - -exit: - return return_value; -} - -#endif /* (defined(WIFEXITED) || defined(MS_WINDOWS)) */ - +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__add_dll_directory__doc__, +"_add_dll_directory($module, /, path)\n" +"--\n" +"\n" +"Add a path to the DLL search path.\n" +"\n" +"This search path is used when resolving dependencies for imported\n" +"extension modules (the module itself is resolved through sys.path),\n" +"and also by ctypes.\n" +"\n" +"Returns an opaque value that may be passed to os.remove_dll_directory\n" +"to remove this directory from the search path."); + +#define OS__ADD_DLL_DIRECTORY_METHODDEF \ + {"_add_dll_directory", (PyCFunction)(void(*)(void))os__add_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, + +static PyObject * +os__add_dll_directory_impl(PyObject *module, path_t *path); + +static PyObject * +os__add_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"path", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "_add_dll_directory", 0}; + PyObject *argsbuf[1]; + path_t path = PATH_T_INITIALIZE("_add_dll_directory", "path", 0, 0); + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + return_value = os__add_dll_directory_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__remove_dll_directory__doc__, +"_remove_dll_directory($module, /, cookie)\n" +"--\n" +"\n" +"Removes a path from the DLL search path.\n" +"\n" +"The parameter is an opaque value that was returned from\n" +"os.add_dll_directory. You can only remove directories that you added\n" +"yourself."); + +#define OS__REMOVE_DLL_DIRECTORY_METHODDEF \ + {"_remove_dll_directory", (PyCFunction)(void(*)(void))os__remove_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, + +static PyObject * +os__remove_dll_directory_impl(PyObject *module, PyObject *cookie); + +static PyObject * +os__remove_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"cookie", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "_remove_dll_directory", 0}; + PyObject *argsbuf[1]; + PyObject *cookie; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + cookie = args[0]; + return_value = os__remove_dll_directory_impl(module, cookie); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#if (defined(WIFEXITED) || defined(MS_WINDOWS)) + +PyDoc_STRVAR(os_waitstatus_to_exitcode__doc__, +"waitstatus_to_exitcode($module, /, status)\n" +"--\n" +"\n" +"Convert a wait status to an exit code.\n" +"\n" +"On Unix:\n" +"\n" +"* If WIFEXITED(status) is true, return WEXITSTATUS(status).\n" +"* If WIFSIGNALED(status) is true, return -WTERMSIG(status).\n" +"* Otherwise, raise a ValueError.\n" +"\n" +"On Windows, return status shifted right by 8 bits.\n" +"\n" +"On Unix, if the process is being traced or if waitpid() was called with\n" +"WUNTRACED option, the caller must first check if WIFSTOPPED(status) is true.\n" +"This function must not be called if WIFSTOPPED(status) is true."); + +#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF \ + {"waitstatus_to_exitcode", (PyCFunction)(void(*)(void))os_waitstatus_to_exitcode, METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, + +static PyObject * +os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj); + +static PyObject * +os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"status", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "waitstatus_to_exitcode", 0}; + PyObject *argsbuf[1]; + PyObject *status_obj; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + status_obj = args[0]; + return_value = os_waitstatus_to_exitcode_impl(module, status_obj); + +exit: + return return_value; +} + +#endif /* (defined(WIFEXITED) || defined(MS_WINDOWS)) */ + #ifndef OS_TTYNAME_METHODDEF #define OS_TTYNAME_METHODDEF #endif /* !defined(OS_TTYNAME_METHODDEF) */ @@ -8954,10 +8954,10 @@ exit: #define OS__GETVOLUMEPATHNAME_METHODDEF #endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */ -#ifndef OS__PATH_SPLITROOT_METHODDEF - #define OS__PATH_SPLITROOT_METHODDEF -#endif /* !defined(OS__PATH_SPLITROOT_METHODDEF) */ - +#ifndef OS__PATH_SPLITROOT_METHODDEF + #define OS__PATH_SPLITROOT_METHODDEF +#endif /* !defined(OS__PATH_SPLITROOT_METHODDEF) */ + #ifndef OS_NICE_METHODDEF #define OS_NICE_METHODDEF #endif /* !defined(OS_NICE_METHODDEF) */ @@ -8986,14 +8986,14 @@ exit: #define OS_EXECVE_METHODDEF #endif /* !defined(OS_EXECVE_METHODDEF) */ -#ifndef OS_POSIX_SPAWN_METHODDEF - #define OS_POSIX_SPAWN_METHODDEF -#endif /* !defined(OS_POSIX_SPAWN_METHODDEF) */ - -#ifndef OS_POSIX_SPAWNP_METHODDEF - #define OS_POSIX_SPAWNP_METHODDEF -#endif /* !defined(OS_POSIX_SPAWNP_METHODDEF) */ - +#ifndef OS_POSIX_SPAWN_METHODDEF + #define OS_POSIX_SPAWN_METHODDEF +#endif /* !defined(OS_POSIX_SPAWN_METHODDEF) */ + +#ifndef OS_POSIX_SPAWNP_METHODDEF + #define OS_POSIX_SPAWNP_METHODDEF +#endif /* !defined(OS_POSIX_SPAWNP_METHODDEF) */ + #ifndef OS_SPAWNV_METHODDEF #define OS_SPAWNV_METHODDEF #endif /* !defined(OS_SPAWNV_METHODDEF) */ @@ -9078,18 +9078,18 @@ exit: #define OS_GETPID_METHODDEF #endif /* !defined(OS_GETPID_METHODDEF) */ -#ifndef OS_GETGROUPLIST_METHODDEF - #define OS_GETGROUPLIST_METHODDEF -#endif /* !defined(OS_GETGROUPLIST_METHODDEF) */ - +#ifndef OS_GETGROUPLIST_METHODDEF + #define OS_GETGROUPLIST_METHODDEF +#endif /* !defined(OS_GETGROUPLIST_METHODDEF) */ + #ifndef OS_GETGROUPS_METHODDEF #define OS_GETGROUPS_METHODDEF #endif /* !defined(OS_GETGROUPS_METHODDEF) */ -#ifndef OS_INITGROUPS_METHODDEF - #define OS_INITGROUPS_METHODDEF -#endif /* !defined(OS_INITGROUPS_METHODDEF) */ - +#ifndef OS_INITGROUPS_METHODDEF + #define OS_INITGROUPS_METHODDEF +#endif /* !defined(OS_INITGROUPS_METHODDEF) */ + #ifndef OS_GETPGID_METHODDEF #define OS_GETPGID_METHODDEF #endif /* !defined(OS_GETPGID_METHODDEF) */ @@ -9174,14 +9174,14 @@ exit: #define OS_WAIT_METHODDEF #endif /* !defined(OS_WAIT_METHODDEF) */ -#ifndef OS_PIDFD_OPEN_METHODDEF - #define OS_PIDFD_OPEN_METHODDEF -#endif /* !defined(OS_PIDFD_OPEN_METHODDEF) */ - -#ifndef OS_READLINK_METHODDEF - #define OS_READLINK_METHODDEF -#endif /* !defined(OS_READLINK_METHODDEF) */ - +#ifndef OS_PIDFD_OPEN_METHODDEF + #define OS_PIDFD_OPEN_METHODDEF +#endif /* !defined(OS_PIDFD_OPEN_METHODDEF) */ + +#ifndef OS_READLINK_METHODDEF + #define OS_READLINK_METHODDEF +#endif /* !defined(OS_READLINK_METHODDEF) */ + #ifndef OS_SYMLINK_METHODDEF #define OS_SYMLINK_METHODDEF #endif /* !defined(OS_SYMLINK_METHODDEF) */ @@ -9226,14 +9226,14 @@ exit: #define OS_PREADV_METHODDEF #endif /* !defined(OS_PREADV_METHODDEF) */ -#ifndef OS_SENDFILE_METHODDEF - #define OS_SENDFILE_METHODDEF -#endif /* !defined(OS_SENDFILE_METHODDEF) */ - -#ifndef OS__FCOPYFILE_METHODDEF - #define OS__FCOPYFILE_METHODDEF -#endif /* !defined(OS__FCOPYFILE_METHODDEF) */ - +#ifndef OS_SENDFILE_METHODDEF + #define OS_SENDFILE_METHODDEF +#endif /* !defined(OS_SENDFILE_METHODDEF) */ + +#ifndef OS__FCOPYFILE_METHODDEF + #define OS__FCOPYFILE_METHODDEF +#endif /* !defined(OS__FCOPYFILE_METHODDEF) */ + #ifndef OS_PIPE_METHODDEF #define OS_PIPE_METHODDEF #endif /* !defined(OS_PIPE_METHODDEF) */ @@ -9254,10 +9254,10 @@ exit: #define OS_PWRITEV_METHODDEF #endif /* !defined(OS_PWRITEV_METHODDEF) */ -#ifndef OS_COPY_FILE_RANGE_METHODDEF - #define OS_COPY_FILE_RANGE_METHODDEF -#endif /* !defined(OS_COPY_FILE_RANGE_METHODDEF) */ - +#ifndef OS_COPY_FILE_RANGE_METHODDEF + #define OS_COPY_FILE_RANGE_METHODDEF +#endif /* !defined(OS_COPY_FILE_RANGE_METHODDEF) */ + #ifndef OS_MKFIFO_METHODDEF #define OS_MKFIFO_METHODDEF #endif /* !defined(OS_MKFIFO_METHODDEF) */ @@ -9402,14 +9402,14 @@ exit: #define OS_LISTXATTR_METHODDEF #endif /* !defined(OS_LISTXATTR_METHODDEF) */ -#ifndef OS_MEMFD_CREATE_METHODDEF - #define OS_MEMFD_CREATE_METHODDEF -#endif /* !defined(OS_MEMFD_CREATE_METHODDEF) */ - -#ifndef OS_GET_TERMINAL_SIZE_METHODDEF - #define OS_GET_TERMINAL_SIZE_METHODDEF -#endif /* !defined(OS_GET_TERMINAL_SIZE_METHODDEF) */ - +#ifndef OS_MEMFD_CREATE_METHODDEF + #define OS_MEMFD_CREATE_METHODDEF +#endif /* !defined(OS_MEMFD_CREATE_METHODDEF) */ + +#ifndef OS_GET_TERMINAL_SIZE_METHODDEF + #define OS_GET_TERMINAL_SIZE_METHODDEF +#endif /* !defined(OS_GET_TERMINAL_SIZE_METHODDEF) */ + #ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF #define OS_GET_HANDLE_INHERITABLE_METHODDEF #endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */ @@ -9418,27 +9418,27 @@ exit: #define OS_SET_HANDLE_INHERITABLE_METHODDEF #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ -#ifndef OS_GET_BLOCKING_METHODDEF - #define OS_GET_BLOCKING_METHODDEF -#endif /* !defined(OS_GET_BLOCKING_METHODDEF) */ - -#ifndef OS_SET_BLOCKING_METHODDEF - #define OS_SET_BLOCKING_METHODDEF -#endif /* !defined(OS_SET_BLOCKING_METHODDEF) */ - +#ifndef OS_GET_BLOCKING_METHODDEF + #define OS_GET_BLOCKING_METHODDEF +#endif /* !defined(OS_GET_BLOCKING_METHODDEF) */ + +#ifndef OS_SET_BLOCKING_METHODDEF + #define OS_SET_BLOCKING_METHODDEF +#endif /* !defined(OS_SET_BLOCKING_METHODDEF) */ + #ifndef OS_GETRANDOM_METHODDEF #define OS_GETRANDOM_METHODDEF #endif /* !defined(OS_GETRANDOM_METHODDEF) */ - -#ifndef OS__ADD_DLL_DIRECTORY_METHODDEF - #define OS__ADD_DLL_DIRECTORY_METHODDEF -#endif /* !defined(OS__ADD_DLL_DIRECTORY_METHODDEF) */ - -#ifndef OS__REMOVE_DLL_DIRECTORY_METHODDEF - #define OS__REMOVE_DLL_DIRECTORY_METHODDEF -#endif /* !defined(OS__REMOVE_DLL_DIRECTORY_METHODDEF) */ - -#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF - #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF -#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=c7c8796918b09139 input=a9049054013a1b77]*/ + +#ifndef OS__ADD_DLL_DIRECTORY_METHODDEF + #define OS__ADD_DLL_DIRECTORY_METHODDEF +#endif /* !defined(OS__ADD_DLL_DIRECTORY_METHODDEF) */ + +#ifndef OS__REMOVE_DLL_DIRECTORY_METHODDEF + #define OS__REMOVE_DLL_DIRECTORY_METHODDEF +#endif /* !defined(OS__REMOVE_DLL_DIRECTORY_METHODDEF) */ + +#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF + #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF +#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ +/*[clinic end generated code: output=c7c8796918b09139 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/pwdmodule.c.h b/contrib/tools/python3/src/Modules/clinic/pwdmodule.c.h index cb83062495..0d9c4dbd99 100644 --- a/contrib/tools/python3/src/Modules/clinic/pwdmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/pwdmodule.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(pwd_getpwuid__doc__, {"getpwuid", (PyCFunction)pwd_getpwuid, METH_O, pwd_getpwuid__doc__}, PyDoc_STRVAR(pwd_getpwnam__doc__, -"getpwnam($module, name, /)\n" +"getpwnam($module, name, /)\n" "--\n" "\n" "Return the password database entry for the given user name.\n" @@ -25,23 +25,23 @@ PyDoc_STRVAR(pwd_getpwnam__doc__, {"getpwnam", (PyCFunction)pwd_getpwnam, METH_O, pwd_getpwnam__doc__}, static PyObject * -pwd_getpwnam_impl(PyObject *module, PyObject *name); +pwd_getpwnam_impl(PyObject *module, PyObject *name); static PyObject * -pwd_getpwnam(PyObject *module, PyObject *arg) +pwd_getpwnam(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - PyObject *name; + PyObject *name; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("getpwnam", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("getpwnam", "argument", "str", arg); goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - name = arg; - return_value = pwd_getpwnam_impl(module, name); + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + name = arg; + return_value = pwd_getpwnam_impl(module, name); exit: return return_value; @@ -74,4 +74,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef PWD_GETPWALL_METHODDEF #define PWD_GETPWALL_METHODDEF #endif /* !defined(PWD_GETPWALL_METHODDEF) */ -/*[clinic end generated code: output=7fceab7f1a85da36 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7fceab7f1a85da36 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h b/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h index ee5907ca7e..6df048f2ff 100644 --- a/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h +++ b/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, "`isfinal\' should be true at end of input."); #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ - {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_FASTCALL, pyexpat_xmlparser_Parse__doc__}, + {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_FASTCALL, pyexpat_xmlparser_Parse__doc__}, static PyObject * pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, @@ -24,23 +24,23 @@ pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *const *args, Py_ssize_t PyObject *data; int isfinal = 0; - if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) { goto exit; } - data = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - isfinal = _PyLong_AsInt(args[1]); - if (isfinal == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + data = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + isfinal = _PyLong_AsInt(args[1]); + if (isfinal == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal); exit: @@ -74,19 +74,19 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg) PyObject *return_value = NULL; const char *base; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("SetBase", "argument", "str", arg); - goto exit; - } - Py_ssize_t base_length; - base = PyUnicode_AsUTF8AndSize(arg, &base_length); - if (base == NULL) { - goto exit; - } - if (strlen(base) != (size_t)base_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("SetBase", "argument", "str", arg); goto exit; } + Py_ssize_t base_length; + base = PyUnicode_AsUTF8AndSize(arg, &base_length); + if (base == NULL) { + goto exit; + } + if (strlen(base) != (size_t)base_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } return_value = pyexpat_xmlparser_SetBase_impl(self, base); exit: @@ -133,14 +133,14 @@ pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(igno } PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__, -"ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n" -" /)\n" +"ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n" +" /)\n" "--\n" "\n" "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ - {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_FASTCALL, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, + {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_FASTCALL, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, static PyObject * pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, @@ -154,44 +154,44 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *con const char *context; const char *encoding = NULL; - if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) { - goto exit; - } - if (args[0] == Py_None) { - context = NULL; - } - else if (PyUnicode_Check(args[0])) { - Py_ssize_t context_length; - context = PyUnicode_AsUTF8AndSize(args[0], &context_length); - if (context == NULL) { - goto exit; - } - if (strlen(context) != (size_t)context_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) { goto exit; } -skip_optional: + if (args[0] == Py_None) { + context = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t context_length; + context = PyUnicode_AsUTF8AndSize(args[0], &context_length); + if (context == NULL) { + goto exit; + } + if (strlen(context) != (size_t)context_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional: return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding); exit: @@ -221,15 +221,15 @@ pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg) PyObject *return_value = NULL; int flag; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(arg); - if (flag == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + flag = _PyLong_AsInt(arg); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag); exit: @@ -249,7 +249,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__, "information to the parser. \'flag\' defaults to True if not provided."); #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ - {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_FASTCALL, pyexpat_xmlparser_UseForeignDTD__doc__}, + {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_FASTCALL, pyexpat_xmlparser_UseForeignDTD__doc__}, static PyObject * pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag); @@ -260,17 +260,17 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *const *args, Py_ PyObject *return_value = NULL; int flag = 1; - if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - flag = PyObject_IsTrue(args[0]); - if (flag < 0) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + flag = PyObject_IsTrue(args[0]); + if (flag < 0) { + goto exit; + } +skip_optional: return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag); exit: @@ -281,13 +281,13 @@ exit: PyDoc_STRVAR(pyexpat_ParserCreate__doc__, "ParserCreate($module, /, encoding=None, namespace_separator=None,\n" -" intern=<unrepresentable>)\n" +" intern=<unrepresentable>)\n" "--\n" "\n" "Return a new XML parser object."); #define PYEXPAT_PARSERCREATE_METHODDEF \ - {"ParserCreate", (PyCFunction)(void(*)(void))pyexpat_ParserCreate, METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, + {"ParserCreate", (PyCFunction)(void(*)(void))pyexpat_ParserCreate, METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, static PyObject * pyexpat_ParserCreate_impl(PyObject *module, const char *encoding, @@ -298,68 +298,68 @@ pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "ParserCreate", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "ParserCreate", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *namespace_separator = NULL; PyObject *intern = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - if (args[0] == Py_None) { - encoding = NULL; - } - else if (PyUnicode_Check(args[0])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[1]) { - if (args[1] == Py_None) { - namespace_separator = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t namespace_separator_length; - namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length); - if (namespace_separator == NULL) { - goto exit; - } - if (strlen(namespace_separator) != (size_t)namespace_separator_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - intern = args[2]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (args[0] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + if (args[1] == Py_None) { + namespace_separator = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t namespace_separator_length; + namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length); + if (namespace_separator == NULL) { + goto exit; + } + if (strlen(namespace_separator) != (size_t)namespace_separator_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + intern = args[2]; +skip_optional_pos: return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); exit: @@ -384,15 +384,15 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg) PyObject *return_value = NULL; long code; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - code = PyLong_AsLong(arg); - if (code == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + code = PyLong_AsLong(arg); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } return_value = pyexpat_ErrorString_impl(module, code); exit: @@ -402,4 +402,4 @@ exit: #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=68ce25024280af41 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=68ce25024280af41 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/resource.c.h b/contrib/tools/python3/src/Modules/clinic/resource.c.h index 80efb714bb..410b82d1a4 100644 --- a/contrib/tools/python3/src/Modules/clinic/resource.c.h +++ b/contrib/tools/python3/src/Modules/clinic/resource.c.h @@ -19,15 +19,15 @@ resource_getrusage(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int who; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - who = _PyLong_AsInt(arg); - if (who == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + who = _PyLong_AsInt(arg); + if (who == -1 && PyErr_Occurred()) { + goto exit; + } return_value = resource_getrusage_impl(module, who); exit: @@ -51,15 +51,15 @@ resource_getrlimit(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int resource; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - resource = _PyLong_AsInt(arg); - if (resource == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + resource = _PyLong_AsInt(arg); + if (resource == -1 && PyErr_Occurred()) { + goto exit; + } return_value = resource_getrlimit_impl(module, resource); exit: @@ -72,7 +72,7 @@ PyDoc_STRVAR(resource_setrlimit__doc__, "\n"); #define RESOURCE_SETRLIMIT_METHODDEF \ - {"setrlimit", (PyCFunction)(void(*)(void))resource_setrlimit, METH_FASTCALL, resource_setrlimit__doc__}, + {"setrlimit", (PyCFunction)(void(*)(void))resource_setrlimit, METH_FASTCALL, resource_setrlimit__doc__}, static PyObject * resource_setrlimit_impl(PyObject *module, int resource, PyObject *limits); @@ -84,19 +84,19 @@ resource_setrlimit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int resource; PyObject *limits; - if (!_PyArg_CheckPositional("setrlimit", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - resource = _PyLong_AsInt(args[0]); - if (resource == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("setrlimit", nargs, 2, 2)) { goto exit; } - limits = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + resource = _PyLong_AsInt(args[0]); + if (resource == -1 && PyErr_Occurred()) { + goto exit; + } + limits = args[1]; return_value = resource_setrlimit_impl(module, resource, limits); exit: @@ -178,4 +178,4 @@ exit: #ifndef RESOURCE_PRLIMIT_METHODDEF #define RESOURCE_PRLIMIT_METHODDEF #endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */ -/*[clinic end generated code: output=ef3034f291156a34 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ef3034f291156a34 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/selectmodule.c.h b/contrib/tools/python3/src/Modules/clinic/selectmodule.c.h index c1072e6ef9..cf97a5c7eb 100644 --- a/contrib/tools/python3/src/Modules/clinic/selectmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/selectmodule.c.h @@ -1,1222 +1,1222 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(select_select__doc__, -"select($module, rlist, wlist, xlist, timeout=None, /)\n" -"--\n" -"\n" -"Wait until one or more file descriptors are ready for some kind of I/O.\n" -"\n" -"The first three arguments are iterables of file descriptors to be waited for:\n" -"rlist -- wait until ready for reading\n" -"wlist -- wait until ready for writing\n" -"xlist -- wait for an \"exceptional condition\"\n" -"If only one kind of condition is required, pass [] for the other lists.\n" -"\n" -"A file descriptor is either a socket or file object, or a small integer\n" -"gotten from a fileno() method call on one of those.\n" -"\n" -"The optional 4th argument specifies a timeout in seconds; it may be\n" -"a floating point number to specify fractions of seconds. If it is absent\n" -"or None, the call will never time out.\n" -"\n" -"The return value is a tuple of three lists corresponding to the first three\n" -"arguments; each contains the subset of the corresponding file descriptors\n" -"that are ready.\n" -"\n" -"*** IMPORTANT NOTICE ***\n" -"On Windows, only sockets are supported; on Unix, all file\n" -"descriptors can be used."); - -#define SELECT_SELECT_METHODDEF \ - {"select", (PyCFunction)(void(*)(void))select_select, METH_FASTCALL, select_select__doc__}, - -static PyObject * -select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, - PyObject *xlist, PyObject *timeout_obj); - -static PyObject * -select_select(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *rlist; - PyObject *wlist; - PyObject *xlist; - PyObject *timeout_obj = Py_None; - - if (!_PyArg_CheckPositional("select", nargs, 3, 4)) { - goto exit; - } - rlist = args[0]; - wlist = args[1]; - xlist = args[2]; - if (nargs < 4) { - goto skip_optional; - } - timeout_obj = args[3]; -skip_optional: - return_value = select_select_impl(module, rlist, wlist, xlist, timeout_obj); - -exit: - return return_value; -} - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) - -PyDoc_STRVAR(select_poll_register__doc__, -"register($self, fd,\n" -" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" -"--\n" -"\n" -"Register a file descriptor with the polling object.\n" -"\n" -" fd\n" -" either an integer, or an object with a fileno() method returning an int\n" -" eventmask\n" -" an optional bitmask describing the type of events to check for"); - -#define SELECT_POLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_poll_register, METH_FASTCALL, select_poll_register__doc__}, - -static PyObject * -select_poll_register_impl(pollObject *self, int fd, unsigned short eventmask); - -static PyObject * -select_poll_register(pollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; - - if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { - goto exit; - } - if (!fildes_converter(args[0], &fd)) { - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { - goto exit; - } -skip_optional: - return_value = select_poll_register_impl(self, fd, eventmask); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) - -PyDoc_STRVAR(select_poll_modify__doc__, -"modify($self, fd, eventmask, /)\n" -"--\n" -"\n" -"Modify an already registered file descriptor.\n" -"\n" -" fd\n" -" either an integer, or an object with a fileno() method returning\n" -" an int\n" -" eventmask\n" -" a bitmask describing the type of events to check for"); - -#define SELECT_POLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_poll_modify, METH_FASTCALL, select_poll_modify__doc__}, - -static PyObject * -select_poll_modify_impl(pollObject *self, int fd, unsigned short eventmask); - -static PyObject * -select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - unsigned short eventmask; - - if (!_PyArg_CheckPositional("modify", nargs, 2, 2)) { - goto exit; - } - if (!fildes_converter(args[0], &fd)) { - goto exit; - } - if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { - goto exit; - } - return_value = select_poll_modify_impl(self, fd, eventmask); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) - -PyDoc_STRVAR(select_poll_unregister__doc__, -"unregister($self, fd, /)\n" -"--\n" -"\n" -"Remove a file descriptor being tracked by the polling object."); - -#define SELECT_POLL_UNREGISTER_METHODDEF \ - {"unregister", (PyCFunction)select_poll_unregister, METH_O, select_poll_unregister__doc__}, - -static PyObject * -select_poll_unregister_impl(pollObject *self, int fd); - -static PyObject * -select_poll_unregister(pollObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - - if (!fildes_converter(arg, &fd)) { - goto exit; - } - return_value = select_poll_unregister_impl(self, fd); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) - -PyDoc_STRVAR(select_poll_poll__doc__, -"poll($self, timeout=None, /)\n" -"--\n" -"\n" -"Polls the set of registered file descriptors.\n" -"\n" -"Returns a list containing any descriptors that have events or errors to\n" -"report, as a list of (fd, event) 2-tuples."); - -#define SELECT_POLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_poll_poll, METH_FASTCALL, select_poll_poll__doc__}, - -static PyObject * -select_poll_poll_impl(pollObject *self, PyObject *timeout_obj); - -static PyObject * -select_poll_poll(pollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *timeout_obj = Py_None; - - if (!_PyArg_CheckPositional("poll", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - timeout_obj = args[0]; -skip_optional: - return_value = select_poll_poll_impl(self, timeout_obj); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_register__doc__, -"register($self, fd,\n" -" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" -"--\n" -"\n" -"Register a file descriptor with the polling object.\n" -"\n" -" fd\n" -" either an integer, or an object with a fileno() method returning\n" -" an int\n" -" eventmask\n" -" an optional bitmask describing the type of events to check for"); - -#define SELECT_DEVPOLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_devpoll_register, METH_FASTCALL, select_devpoll_register__doc__}, - -static PyObject * -select_devpoll_register_impl(devpollObject *self, int fd, - unsigned short eventmask); - -static PyObject * -select_devpoll_register(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; - - if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { - goto exit; - } - if (!fildes_converter(args[0], &fd)) { - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { - goto exit; - } -skip_optional: - return_value = select_devpoll_register_impl(self, fd, eventmask); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_modify__doc__, -"modify($self, fd,\n" -" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" -"--\n" -"\n" -"Modify a possible already registered file descriptor.\n" -"\n" -" fd\n" -" either an integer, or an object with a fileno() method returning\n" -" an int\n" -" eventmask\n" -" an optional bitmask describing the type of events to check for"); - -#define SELECT_DEVPOLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_devpoll_modify, METH_FASTCALL, select_devpoll_modify__doc__}, - -static PyObject * -select_devpoll_modify_impl(devpollObject *self, int fd, - unsigned short eventmask); - -static PyObject * -select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; - - if (!_PyArg_CheckPositional("modify", nargs, 1, 2)) { - goto exit; - } - if (!fildes_converter(args[0], &fd)) { - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { - goto exit; - } -skip_optional: - return_value = select_devpoll_modify_impl(self, fd, eventmask); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_unregister__doc__, -"unregister($self, fd, /)\n" -"--\n" -"\n" -"Remove a file descriptor being tracked by the polling object."); - -#define SELECT_DEVPOLL_UNREGISTER_METHODDEF \ - {"unregister", (PyCFunction)select_devpoll_unregister, METH_O, select_devpoll_unregister__doc__}, - -static PyObject * -select_devpoll_unregister_impl(devpollObject *self, int fd); - -static PyObject * -select_devpoll_unregister(devpollObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - - if (!fildes_converter(arg, &fd)) { - goto exit; - } - return_value = select_devpoll_unregister_impl(self, fd); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_poll__doc__, -"poll($self, timeout=None, /)\n" -"--\n" -"\n" -"Polls the set of registered file descriptors.\n" -"\n" -"Returns a list containing any descriptors that have events or errors to\n" -"report, as a list of (fd, event) 2-tuples."); - -#define SELECT_DEVPOLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_devpoll_poll, METH_FASTCALL, select_devpoll_poll__doc__}, - -static PyObject * -select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj); - -static PyObject * -select_devpoll_poll(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *timeout_obj = Py_None; - - if (!_PyArg_CheckPositional("poll", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - timeout_obj = args[0]; -skip_optional: - return_value = select_devpoll_poll_impl(self, timeout_obj); - -exit: - return return_value; -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_close__doc__, -"close($self, /)\n" -"--\n" -"\n" -"Close the devpoll file descriptor.\n" -"\n" -"Further operations on the devpoll object will raise an exception."); - -#define SELECT_DEVPOLL_CLOSE_METHODDEF \ - {"close", (PyCFunction)select_devpoll_close, METH_NOARGS, select_devpoll_close__doc__}, - -static PyObject * -select_devpoll_close_impl(devpollObject *self); - -static PyObject * -select_devpoll_close(devpollObject *self, PyObject *Py_UNUSED(ignored)) -{ - return select_devpoll_close_impl(self); -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll_fileno__doc__, -"fileno($self, /)\n" -"--\n" -"\n" -"Return the file descriptor."); - -#define SELECT_DEVPOLL_FILENO_METHODDEF \ - {"fileno", (PyCFunction)select_devpoll_fileno, METH_NOARGS, select_devpoll_fileno__doc__}, - -static PyObject * -select_devpoll_fileno_impl(devpollObject *self); - -static PyObject * -select_devpoll_fileno(devpollObject *self, PyObject *Py_UNUSED(ignored)) -{ - return select_devpoll_fileno_impl(self); -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) - -PyDoc_STRVAR(select_poll__doc__, -"poll($module, /)\n" -"--\n" -"\n" -"Returns a polling object.\n" -"\n" -"This object supports registering and unregistering file descriptors, and then\n" -"polling them for I/O events."); - -#define SELECT_POLL_METHODDEF \ - {"poll", (PyCFunction)select_poll, METH_NOARGS, select_poll__doc__}, - -static PyObject * -select_poll_impl(PyObject *module); - -static PyObject * -select_poll(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return select_poll_impl(module); -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ - -#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) - -PyDoc_STRVAR(select_devpoll__doc__, -"devpoll($module, /)\n" -"--\n" -"\n" -"Returns a polling object.\n" -"\n" -"This object supports registering and unregistering file descriptors, and then\n" -"polling them for I/O events."); - -#define SELECT_DEVPOLL_METHODDEF \ - {"devpoll", (PyCFunction)select_devpoll, METH_NOARGS, select_devpoll__doc__}, - -static PyObject * -select_devpoll_impl(PyObject *module); - -static PyObject * -select_devpoll(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return select_devpoll_impl(module); -} - -#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll__doc__, -"epoll(sizehint=-1, flags=0)\n" -"--\n" -"\n" -"Returns an epolling object.\n" -"\n" -" sizehint\n" -" The expected number of events to be registered. It must be positive,\n" -" or -1 to use the default. It is only used on older systems where\n" -" epoll_create1() is not available; otherwise it has no effect (though its\n" -" value is still checked).\n" -" flags\n" -" Deprecated and completely ignored. However, when supplied, its value\n" -" must be 0 or select.EPOLL_CLOEXEC, otherwise OSError is raised."); - -static PyObject * -select_epoll_impl(PyTypeObject *type, int sizehint, int flags); - -static PyObject * -select_epoll(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"sizehint", "flags", NULL}; - 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; - - 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: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_close__doc__, -"close($self, /)\n" -"--\n" -"\n" -"Close the epoll control file descriptor.\n" -"\n" -"Further operations on the epoll object will raise an exception."); - -#define SELECT_EPOLL_CLOSE_METHODDEF \ - {"close", (PyCFunction)select_epoll_close, METH_NOARGS, select_epoll_close__doc__}, - -static PyObject * -select_epoll_close_impl(pyEpoll_Object *self); - -static PyObject * -select_epoll_close(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) -{ - return select_epoll_close_impl(self); -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_fileno__doc__, -"fileno($self, /)\n" -"--\n" -"\n" -"Return the epoll control file descriptor."); - -#define SELECT_EPOLL_FILENO_METHODDEF \ - {"fileno", (PyCFunction)select_epoll_fileno, METH_NOARGS, select_epoll_fileno__doc__}, - -static PyObject * -select_epoll_fileno_impl(pyEpoll_Object *self); - -static PyObject * -select_epoll_fileno(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) -{ - return select_epoll_fileno_impl(self); -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_fromfd__doc__, -"fromfd($type, fd, /)\n" -"--\n" -"\n" -"Create an epoll object from a given control fd."); - -#define SELECT_EPOLL_FROMFD_METHODDEF \ - {"fromfd", (PyCFunction)select_epoll_fromfd, METH_O|METH_CLASS, select_epoll_fromfd__doc__}, - -static PyObject * -select_epoll_fromfd_impl(PyTypeObject *type, int fd); - -static PyObject * -select_epoll_fromfd(PyTypeObject *type, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = select_epoll_fromfd_impl(type, fd); - -exit: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_register__doc__, -"register($self, /, fd,\n" -" eventmask=select.EPOLLIN | select.EPOLLPRI | select.EPOLLOUT)\n" -"--\n" -"\n" -"Registers a new fd or raises an OSError if the fd is already registered.\n" -"\n" -" fd\n" -" the target file descriptor of the operation\n" -" eventmask\n" -" a bit set composed of the various EPOLL constants\n" -"\n" -"The epoll interface supports all file descriptors that support poll."); - -#define SELECT_EPOLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_epoll_register, METH_FASTCALL|METH_KEYWORDS, select_epoll_register__doc__}, - -static PyObject * -select_epoll_register_impl(pyEpoll_Object *self, int fd, - unsigned int eventmask); - -static PyObject * -select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"fd", "eventmask", NULL}; - 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; - - 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: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_modify__doc__, -"modify($self, /, fd, eventmask)\n" -"--\n" -"\n" -"Modify event mask for a registered file descriptor.\n" -"\n" -" fd\n" -" the target file descriptor of the operation\n" -" eventmask\n" -" a bit set composed of the various EPOLL constants"); - -#define SELECT_EPOLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_epoll_modify, METH_FASTCALL|METH_KEYWORDS, select_epoll_modify__doc__}, - -static PyObject * -select_epoll_modify_impl(pyEpoll_Object *self, int fd, - unsigned int eventmask); - -static PyObject * -select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"fd", "eventmask", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "modify", 0}; - PyObject *argsbuf[2]; - int fd; - unsigned int 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); - -exit: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_unregister__doc__, -"unregister($self, /, fd)\n" -"--\n" -"\n" -"Remove a registered file descriptor from the epoll object.\n" -"\n" -" fd\n" -" the target file descriptor of the operation"); - -#define SELECT_EPOLL_UNREGISTER_METHODDEF \ - {"unregister", (PyCFunction)(void(*)(void))select_epoll_unregister, METH_FASTCALL|METH_KEYWORDS, select_epoll_unregister__doc__}, - -static PyObject * -select_epoll_unregister_impl(pyEpoll_Object *self, int fd); - -static PyObject * -select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "unregister", 0}; - PyObject *argsbuf[1]; - int 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); - -exit: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll_poll__doc__, -"poll($self, /, timeout=None, maxevents=-1)\n" -"--\n" -"\n" -"Wait for events on the epoll file descriptor.\n" -"\n" -" timeout\n" -" the maximum time to wait in seconds (as float);\n" -" a timeout of None or -1 makes poll wait indefinitely\n" -" maxevents\n" -" the maximum number of events returned; -1 means no limit\n" -"\n" -"Returns a list containing any descriptors that have events to report,\n" -"as a list of (fd, events) 2-tuples."); - -#define SELECT_EPOLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_epoll_poll, METH_FASTCALL|METH_KEYWORDS, select_epoll_poll__doc__}, - -static PyObject * -select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj, - int maxevents); - -static PyObject * -select_epoll_poll(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"timeout", "maxevents", NULL}; - 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; - - 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: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll___enter____doc__, -"__enter__($self, /)\n" -"--\n" -"\n"); - -#define SELECT_EPOLL___ENTER___METHODDEF \ - {"__enter__", (PyCFunction)select_epoll___enter__, METH_NOARGS, select_epoll___enter____doc__}, - -static PyObject * -select_epoll___enter___impl(pyEpoll_Object *self); - -static PyObject * -select_epoll___enter__(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) -{ - return select_epoll___enter___impl(self); -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_EPOLL) - -PyDoc_STRVAR(select_epoll___exit____doc__, -"__exit__($self, exc_type=None, exc_value=None, exc_tb=None, /)\n" -"--\n" -"\n"); - -#define SELECT_EPOLL___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))select_epoll___exit__, METH_FASTCALL, select_epoll___exit____doc__}, - -static PyObject * -select_epoll___exit___impl(pyEpoll_Object *self, PyObject *exc_type, - PyObject *exc_value, PyObject *exc_tb); - -static PyObject * -select_epoll___exit__(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *exc_type = Py_None; - PyObject *exc_value = Py_None; - PyObject *exc_tb = Py_None; - - if (!_PyArg_CheckPositional("__exit__", nargs, 0, 3)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - exc_type = args[0]; - if (nargs < 2) { - goto skip_optional; - } - exc_value = args[1]; - if (nargs < 3) { - goto skip_optional; - } - exc_tb = args[2]; -skip_optional: - return_value = select_epoll___exit___impl(self, exc_type, exc_value, exc_tb); - -exit: - return return_value; -} - -#endif /* defined(HAVE_EPOLL) */ - -#if defined(HAVE_KQUEUE) - -PyDoc_STRVAR(select_kqueue__doc__, -"kqueue()\n" -"--\n" -"\n" -"Kqueue syscall wrapper.\n" -"\n" -"For example, to start watching a socket for input:\n" -">>> kq = kqueue()\n" -">>> sock = socket()\n" -">>> sock.connect((host, port))\n" -">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)\n" -"\n" -"To wait one second for it to become writeable:\n" -">>> kq.control(None, 1, 1000)\n" -"\n" -"To stop listening:\n" -">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0)"); - -static PyObject * -select_kqueue_impl(PyTypeObject *type); - -static PyObject * -select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - - if ((type == _selectstate_global->kqueue_queue_Type) && - !_PyArg_NoPositional("kqueue", args)) { - goto exit; - } - if ((type == _selectstate_global->kqueue_queue_Type) && - !_PyArg_NoKeywords("kqueue", kwargs)) { - goto exit; - } - return_value = select_kqueue_impl(type); - -exit: - return return_value; -} - -#endif /* defined(HAVE_KQUEUE) */ - -#if defined(HAVE_KQUEUE) - -PyDoc_STRVAR(select_kqueue_close__doc__, -"close($self, /)\n" -"--\n" -"\n" -"Close the kqueue control file descriptor.\n" -"\n" -"Further operations on the kqueue object will raise an exception."); - -#define SELECT_KQUEUE_CLOSE_METHODDEF \ - {"close", (PyCFunction)select_kqueue_close, METH_NOARGS, select_kqueue_close__doc__}, - -static PyObject * -select_kqueue_close_impl(kqueue_queue_Object *self); - -static PyObject * -select_kqueue_close(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored)) -{ - return select_kqueue_close_impl(self); -} - -#endif /* defined(HAVE_KQUEUE) */ - -#if defined(HAVE_KQUEUE) - -PyDoc_STRVAR(select_kqueue_fileno__doc__, -"fileno($self, /)\n" -"--\n" -"\n" -"Return the kqueue control file descriptor."); - -#define SELECT_KQUEUE_FILENO_METHODDEF \ - {"fileno", (PyCFunction)select_kqueue_fileno, METH_NOARGS, select_kqueue_fileno__doc__}, - -static PyObject * -select_kqueue_fileno_impl(kqueue_queue_Object *self); - -static PyObject * -select_kqueue_fileno(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored)) -{ - return select_kqueue_fileno_impl(self); -} - -#endif /* defined(HAVE_KQUEUE) */ - -#if defined(HAVE_KQUEUE) - -PyDoc_STRVAR(select_kqueue_fromfd__doc__, -"fromfd($type, fd, /)\n" -"--\n" -"\n" -"Create a kqueue object from a given control fd."); - -#define SELECT_KQUEUE_FROMFD_METHODDEF \ - {"fromfd", (PyCFunction)select_kqueue_fromfd, METH_O|METH_CLASS, select_kqueue_fromfd__doc__}, - -static PyObject * -select_kqueue_fromfd_impl(PyTypeObject *type, int fd); - -static PyObject * -select_kqueue_fromfd(PyTypeObject *type, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = select_kqueue_fromfd_impl(type, fd); - -exit: - return return_value; -} - -#endif /* defined(HAVE_KQUEUE) */ - -#if defined(HAVE_KQUEUE) - -PyDoc_STRVAR(select_kqueue_control__doc__, -"control($self, changelist, maxevents, timeout=None, /)\n" -"--\n" -"\n" -"Calls the kernel kevent function.\n" -"\n" -" changelist\n" -" Must be an iterable of kevent objects describing the changes to be made\n" -" to the kernel\'s watch list or None.\n" -" maxevents\n" -" The maximum number of events that the kernel will return.\n" -" timeout\n" -" The maximum time to wait in seconds, or else None to wait forever.\n" -" This accepts floats for smaller timeouts, too."); - -#define SELECT_KQUEUE_CONTROL_METHODDEF \ - {"control", (PyCFunction)(void(*)(void))select_kqueue_control, METH_FASTCALL, select_kqueue_control__doc__}, - -static PyObject * -select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist, - int maxevents, PyObject *otimeout); - -static PyObject * -select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *changelist; - int maxevents; - PyObject *otimeout = Py_None; - - if (!_PyArg_CheckPositional("control", nargs, 2, 3)) { - goto exit; - } - changelist = args[0]; - 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; - } - if (nargs < 3) { - goto skip_optional; - } - otimeout = args[2]; -skip_optional: - return_value = select_kqueue_control_impl(self, changelist, maxevents, otimeout); - -exit: - return return_value; -} - -#endif /* defined(HAVE_KQUEUE) */ - -#ifndef SELECT_POLL_REGISTER_METHODDEF - #define SELECT_POLL_REGISTER_METHODDEF -#endif /* !defined(SELECT_POLL_REGISTER_METHODDEF) */ - -#ifndef SELECT_POLL_MODIFY_METHODDEF - #define SELECT_POLL_MODIFY_METHODDEF -#endif /* !defined(SELECT_POLL_MODIFY_METHODDEF) */ - -#ifndef SELECT_POLL_UNREGISTER_METHODDEF - #define SELECT_POLL_UNREGISTER_METHODDEF -#endif /* !defined(SELECT_POLL_UNREGISTER_METHODDEF) */ - -#ifndef SELECT_POLL_POLL_METHODDEF - #define SELECT_POLL_POLL_METHODDEF -#endif /* !defined(SELECT_POLL_POLL_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_REGISTER_METHODDEF - #define SELECT_DEVPOLL_REGISTER_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_REGISTER_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_MODIFY_METHODDEF - #define SELECT_DEVPOLL_MODIFY_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_MODIFY_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_UNREGISTER_METHODDEF - #define SELECT_DEVPOLL_UNREGISTER_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_UNREGISTER_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_POLL_METHODDEF - #define SELECT_DEVPOLL_POLL_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_POLL_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_CLOSE_METHODDEF - #define SELECT_DEVPOLL_CLOSE_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_CLOSE_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_FILENO_METHODDEF - #define SELECT_DEVPOLL_FILENO_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_FILENO_METHODDEF) */ - -#ifndef SELECT_POLL_METHODDEF - #define SELECT_POLL_METHODDEF -#endif /* !defined(SELECT_POLL_METHODDEF) */ - -#ifndef SELECT_DEVPOLL_METHODDEF - #define SELECT_DEVPOLL_METHODDEF -#endif /* !defined(SELECT_DEVPOLL_METHODDEF) */ - -#ifndef SELECT_EPOLL_CLOSE_METHODDEF - #define SELECT_EPOLL_CLOSE_METHODDEF -#endif /* !defined(SELECT_EPOLL_CLOSE_METHODDEF) */ - -#ifndef SELECT_EPOLL_FILENO_METHODDEF - #define SELECT_EPOLL_FILENO_METHODDEF -#endif /* !defined(SELECT_EPOLL_FILENO_METHODDEF) */ - -#ifndef SELECT_EPOLL_FROMFD_METHODDEF - #define SELECT_EPOLL_FROMFD_METHODDEF -#endif /* !defined(SELECT_EPOLL_FROMFD_METHODDEF) */ - -#ifndef SELECT_EPOLL_REGISTER_METHODDEF - #define SELECT_EPOLL_REGISTER_METHODDEF -#endif /* !defined(SELECT_EPOLL_REGISTER_METHODDEF) */ - -#ifndef SELECT_EPOLL_MODIFY_METHODDEF - #define SELECT_EPOLL_MODIFY_METHODDEF -#endif /* !defined(SELECT_EPOLL_MODIFY_METHODDEF) */ - -#ifndef SELECT_EPOLL_UNREGISTER_METHODDEF - #define SELECT_EPOLL_UNREGISTER_METHODDEF -#endif /* !defined(SELECT_EPOLL_UNREGISTER_METHODDEF) */ - -#ifndef SELECT_EPOLL_POLL_METHODDEF - #define SELECT_EPOLL_POLL_METHODDEF -#endif /* !defined(SELECT_EPOLL_POLL_METHODDEF) */ - -#ifndef SELECT_EPOLL___ENTER___METHODDEF - #define SELECT_EPOLL___ENTER___METHODDEF -#endif /* !defined(SELECT_EPOLL___ENTER___METHODDEF) */ - -#ifndef SELECT_EPOLL___EXIT___METHODDEF - #define SELECT_EPOLL___EXIT___METHODDEF -#endif /* !defined(SELECT_EPOLL___EXIT___METHODDEF) */ - -#ifndef SELECT_KQUEUE_CLOSE_METHODDEF - #define SELECT_KQUEUE_CLOSE_METHODDEF -#endif /* !defined(SELECT_KQUEUE_CLOSE_METHODDEF) */ - -#ifndef SELECT_KQUEUE_FILENO_METHODDEF - #define SELECT_KQUEUE_FILENO_METHODDEF -#endif /* !defined(SELECT_KQUEUE_FILENO_METHODDEF) */ - -#ifndef SELECT_KQUEUE_FROMFD_METHODDEF - #define SELECT_KQUEUE_FROMFD_METHODDEF -#endif /* !defined(SELECT_KQUEUE_FROMFD_METHODDEF) */ - -#ifndef SELECT_KQUEUE_CONTROL_METHODDEF - #define SELECT_KQUEUE_CONTROL_METHODDEF -#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=ef42c3485a8fe3a0 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(select_select__doc__, +"select($module, rlist, wlist, xlist, timeout=None, /)\n" +"--\n" +"\n" +"Wait until one or more file descriptors are ready for some kind of I/O.\n" +"\n" +"The first three arguments are iterables of file descriptors to be waited for:\n" +"rlist -- wait until ready for reading\n" +"wlist -- wait until ready for writing\n" +"xlist -- wait for an \"exceptional condition\"\n" +"If only one kind of condition is required, pass [] for the other lists.\n" +"\n" +"A file descriptor is either a socket or file object, or a small integer\n" +"gotten from a fileno() method call on one of those.\n" +"\n" +"The optional 4th argument specifies a timeout in seconds; it may be\n" +"a floating point number to specify fractions of seconds. If it is absent\n" +"or None, the call will never time out.\n" +"\n" +"The return value is a tuple of three lists corresponding to the first three\n" +"arguments; each contains the subset of the corresponding file descriptors\n" +"that are ready.\n" +"\n" +"*** IMPORTANT NOTICE ***\n" +"On Windows, only sockets are supported; on Unix, all file\n" +"descriptors can be used."); + +#define SELECT_SELECT_METHODDEF \ + {"select", (PyCFunction)(void(*)(void))select_select, METH_FASTCALL, select_select__doc__}, + +static PyObject * +select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, + PyObject *xlist, PyObject *timeout_obj); + +static PyObject * +select_select(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *rlist; + PyObject *wlist; + PyObject *xlist; + PyObject *timeout_obj = Py_None; + + if (!_PyArg_CheckPositional("select", nargs, 3, 4)) { + goto exit; + } + rlist = args[0]; + wlist = args[1]; + xlist = args[2]; + if (nargs < 4) { + goto skip_optional; + } + timeout_obj = args[3]; +skip_optional: + return_value = select_select_impl(module, rlist, wlist, xlist, timeout_obj); + +exit: + return return_value; +} + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) + +PyDoc_STRVAR(select_poll_register__doc__, +"register($self, fd,\n" +" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" +"--\n" +"\n" +"Register a file descriptor with the polling object.\n" +"\n" +" fd\n" +" either an integer, or an object with a fileno() method returning an int\n" +" eventmask\n" +" an optional bitmask describing the type of events to check for"); + +#define SELECT_POLL_REGISTER_METHODDEF \ + {"register", (PyCFunction)(void(*)(void))select_poll_register, METH_FASTCALL, select_poll_register__doc__}, + +static PyObject * +select_poll_register_impl(pollObject *self, int fd, unsigned short eventmask); + +static PyObject * +select_poll_register(pollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd; + unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; + + if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { + goto exit; + } +skip_optional: + return_value = select_poll_register_impl(self, fd, eventmask); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) + +PyDoc_STRVAR(select_poll_modify__doc__, +"modify($self, fd, eventmask, /)\n" +"--\n" +"\n" +"Modify an already registered file descriptor.\n" +"\n" +" fd\n" +" either an integer, or an object with a fileno() method returning\n" +" an int\n" +" eventmask\n" +" a bitmask describing the type of events to check for"); + +#define SELECT_POLL_MODIFY_METHODDEF \ + {"modify", (PyCFunction)(void(*)(void))select_poll_modify, METH_FASTCALL, select_poll_modify__doc__}, + +static PyObject * +select_poll_modify_impl(pollObject *self, int fd, unsigned short eventmask); + +static PyObject * +select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd; + unsigned short eventmask; + + if (!_PyArg_CheckPositional("modify", nargs, 2, 2)) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { + goto exit; + } + return_value = select_poll_modify_impl(self, fd, eventmask); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) + +PyDoc_STRVAR(select_poll_unregister__doc__, +"unregister($self, fd, /)\n" +"--\n" +"\n" +"Remove a file descriptor being tracked by the polling object."); + +#define SELECT_POLL_UNREGISTER_METHODDEF \ + {"unregister", (PyCFunction)select_poll_unregister, METH_O, select_poll_unregister__doc__}, + +static PyObject * +select_poll_unregister_impl(pollObject *self, int fd); + +static PyObject * +select_poll_unregister(pollObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (!fildes_converter(arg, &fd)) { + goto exit; + } + return_value = select_poll_unregister_impl(self, fd); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) + +PyDoc_STRVAR(select_poll_poll__doc__, +"poll($self, timeout=None, /)\n" +"--\n" +"\n" +"Polls the set of registered file descriptors.\n" +"\n" +"Returns a list containing any descriptors that have events or errors to\n" +"report, as a list of (fd, event) 2-tuples."); + +#define SELECT_POLL_POLL_METHODDEF \ + {"poll", (PyCFunction)(void(*)(void))select_poll_poll, METH_FASTCALL, select_poll_poll__doc__}, + +static PyObject * +select_poll_poll_impl(pollObject *self, PyObject *timeout_obj); + +static PyObject * +select_poll_poll(pollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *timeout_obj = Py_None; + + if (!_PyArg_CheckPositional("poll", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + timeout_obj = args[0]; +skip_optional: + return_value = select_poll_poll_impl(self, timeout_obj); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_register__doc__, +"register($self, fd,\n" +" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" +"--\n" +"\n" +"Register a file descriptor with the polling object.\n" +"\n" +" fd\n" +" either an integer, or an object with a fileno() method returning\n" +" an int\n" +" eventmask\n" +" an optional bitmask describing the type of events to check for"); + +#define SELECT_DEVPOLL_REGISTER_METHODDEF \ + {"register", (PyCFunction)(void(*)(void))select_devpoll_register, METH_FASTCALL, select_devpoll_register__doc__}, + +static PyObject * +select_devpoll_register_impl(devpollObject *self, int fd, + unsigned short eventmask); + +static PyObject * +select_devpoll_register(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd; + unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; + + if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { + goto exit; + } +skip_optional: + return_value = select_devpoll_register_impl(self, fd, eventmask); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_modify__doc__, +"modify($self, fd,\n" +" eventmask=select.POLLIN | select.POLLPRI | select.POLLOUT, /)\n" +"--\n" +"\n" +"Modify a possible already registered file descriptor.\n" +"\n" +" fd\n" +" either an integer, or an object with a fileno() method returning\n" +" an int\n" +" eventmask\n" +" an optional bitmask describing the type of events to check for"); + +#define SELECT_DEVPOLL_MODIFY_METHODDEF \ + {"modify", (PyCFunction)(void(*)(void))select_devpoll_modify, METH_FASTCALL, select_devpoll_modify__doc__}, + +static PyObject * +select_devpoll_modify_impl(devpollObject *self, int fd, + unsigned short eventmask); + +static PyObject * +select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int fd; + unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; + + if (!_PyArg_CheckPositional("modify", nargs, 1, 2)) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { + goto exit; + } +skip_optional: + return_value = select_devpoll_modify_impl(self, fd, eventmask); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_unregister__doc__, +"unregister($self, fd, /)\n" +"--\n" +"\n" +"Remove a file descriptor being tracked by the polling object."); + +#define SELECT_DEVPOLL_UNREGISTER_METHODDEF \ + {"unregister", (PyCFunction)select_devpoll_unregister, METH_O, select_devpoll_unregister__doc__}, + +static PyObject * +select_devpoll_unregister_impl(devpollObject *self, int fd); + +static PyObject * +select_devpoll_unregister(devpollObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (!fildes_converter(arg, &fd)) { + goto exit; + } + return_value = select_devpoll_unregister_impl(self, fd); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_poll__doc__, +"poll($self, timeout=None, /)\n" +"--\n" +"\n" +"Polls the set of registered file descriptors.\n" +"\n" +"Returns a list containing any descriptors that have events or errors to\n" +"report, as a list of (fd, event) 2-tuples."); + +#define SELECT_DEVPOLL_POLL_METHODDEF \ + {"poll", (PyCFunction)(void(*)(void))select_devpoll_poll, METH_FASTCALL, select_devpoll_poll__doc__}, + +static PyObject * +select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj); + +static PyObject * +select_devpoll_poll(devpollObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *timeout_obj = Py_None; + + if (!_PyArg_CheckPositional("poll", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + timeout_obj = args[0]; +skip_optional: + return_value = select_devpoll_poll_impl(self, timeout_obj); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_close__doc__, +"close($self, /)\n" +"--\n" +"\n" +"Close the devpoll file descriptor.\n" +"\n" +"Further operations on the devpoll object will raise an exception."); + +#define SELECT_DEVPOLL_CLOSE_METHODDEF \ + {"close", (PyCFunction)select_devpoll_close, METH_NOARGS, select_devpoll_close__doc__}, + +static PyObject * +select_devpoll_close_impl(devpollObject *self); + +static PyObject * +select_devpoll_close(devpollObject *self, PyObject *Py_UNUSED(ignored)) +{ + return select_devpoll_close_impl(self); +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll_fileno__doc__, +"fileno($self, /)\n" +"--\n" +"\n" +"Return the file descriptor."); + +#define SELECT_DEVPOLL_FILENO_METHODDEF \ + {"fileno", (PyCFunction)select_devpoll_fileno, METH_NOARGS, select_devpoll_fileno__doc__}, + +static PyObject * +select_devpoll_fileno_impl(devpollObject *self); + +static PyObject * +select_devpoll_fileno(devpollObject *self, PyObject *Py_UNUSED(ignored)) +{ + return select_devpoll_fileno_impl(self); +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) + +PyDoc_STRVAR(select_poll__doc__, +"poll($module, /)\n" +"--\n" +"\n" +"Returns a polling object.\n" +"\n" +"This object supports registering and unregistering file descriptors, and then\n" +"polling them for I/O events."); + +#define SELECT_POLL_METHODDEF \ + {"poll", (PyCFunction)select_poll, METH_NOARGS, select_poll__doc__}, + +static PyObject * +select_poll_impl(PyObject *module); + +static PyObject * +select_poll(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return select_poll_impl(module); +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) */ + +#if (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) + +PyDoc_STRVAR(select_devpoll__doc__, +"devpoll($module, /)\n" +"--\n" +"\n" +"Returns a polling object.\n" +"\n" +"This object supports registering and unregistering file descriptors, and then\n" +"polling them for I/O events."); + +#define SELECT_DEVPOLL_METHODDEF \ + {"devpoll", (PyCFunction)select_devpoll, METH_NOARGS, select_devpoll__doc__}, + +static PyObject * +select_devpoll_impl(PyObject *module); + +static PyObject * +select_devpoll(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return select_devpoll_impl(module); +} + +#endif /* (defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)) && defined(HAVE_SYS_DEVPOLL_H) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll__doc__, +"epoll(sizehint=-1, flags=0)\n" +"--\n" +"\n" +"Returns an epolling object.\n" +"\n" +" sizehint\n" +" The expected number of events to be registered. It must be positive,\n" +" or -1 to use the default. It is only used on older systems where\n" +" epoll_create1() is not available; otherwise it has no effect (though its\n" +" value is still checked).\n" +" flags\n" +" Deprecated and completely ignored. However, when supplied, its value\n" +" must be 0 or select.EPOLL_CLOEXEC, otherwise OSError is raised."); + +static PyObject * +select_epoll_impl(PyTypeObject *type, int sizehint, int flags); + +static PyObject * +select_epoll(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sizehint", "flags", NULL}; + 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; + + 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: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_close__doc__, +"close($self, /)\n" +"--\n" +"\n" +"Close the epoll control file descriptor.\n" +"\n" +"Further operations on the epoll object will raise an exception."); + +#define SELECT_EPOLL_CLOSE_METHODDEF \ + {"close", (PyCFunction)select_epoll_close, METH_NOARGS, select_epoll_close__doc__}, + +static PyObject * +select_epoll_close_impl(pyEpoll_Object *self); + +static PyObject * +select_epoll_close(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) +{ + return select_epoll_close_impl(self); +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_fileno__doc__, +"fileno($self, /)\n" +"--\n" +"\n" +"Return the epoll control file descriptor."); + +#define SELECT_EPOLL_FILENO_METHODDEF \ + {"fileno", (PyCFunction)select_epoll_fileno, METH_NOARGS, select_epoll_fileno__doc__}, + +static PyObject * +select_epoll_fileno_impl(pyEpoll_Object *self); + +static PyObject * +select_epoll_fileno(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) +{ + return select_epoll_fileno_impl(self); +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_fromfd__doc__, +"fromfd($type, fd, /)\n" +"--\n" +"\n" +"Create an epoll object from a given control fd."); + +#define SELECT_EPOLL_FROMFD_METHODDEF \ + {"fromfd", (PyCFunction)select_epoll_fromfd, METH_O|METH_CLASS, select_epoll_fromfd__doc__}, + +static PyObject * +select_epoll_fromfd_impl(PyTypeObject *type, int fd); + +static PyObject * +select_epoll_fromfd(PyTypeObject *type, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = select_epoll_fromfd_impl(type, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_register__doc__, +"register($self, /, fd,\n" +" eventmask=select.EPOLLIN | select.EPOLLPRI | select.EPOLLOUT)\n" +"--\n" +"\n" +"Registers a new fd or raises an OSError if the fd is already registered.\n" +"\n" +" fd\n" +" the target file descriptor of the operation\n" +" eventmask\n" +" a bit set composed of the various EPOLL constants\n" +"\n" +"The epoll interface supports all file descriptors that support poll."); + +#define SELECT_EPOLL_REGISTER_METHODDEF \ + {"register", (PyCFunction)(void(*)(void))select_epoll_register, METH_FASTCALL|METH_KEYWORDS, select_epoll_register__doc__}, + +static PyObject * +select_epoll_register_impl(pyEpoll_Object *self, int fd, + unsigned int eventmask); + +static PyObject * +select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"fd", "eventmask", NULL}; + 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; + + 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: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_modify__doc__, +"modify($self, /, fd, eventmask)\n" +"--\n" +"\n" +"Modify event mask for a registered file descriptor.\n" +"\n" +" fd\n" +" the target file descriptor of the operation\n" +" eventmask\n" +" a bit set composed of the various EPOLL constants"); + +#define SELECT_EPOLL_MODIFY_METHODDEF \ + {"modify", (PyCFunction)(void(*)(void))select_epoll_modify, METH_FASTCALL|METH_KEYWORDS, select_epoll_modify__doc__}, + +static PyObject * +select_epoll_modify_impl(pyEpoll_Object *self, int fd, + unsigned int eventmask); + +static PyObject * +select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"fd", "eventmask", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "modify", 0}; + PyObject *argsbuf[2]; + int fd; + unsigned int 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); + +exit: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_unregister__doc__, +"unregister($self, /, fd)\n" +"--\n" +"\n" +"Remove a registered file descriptor from the epoll object.\n" +"\n" +" fd\n" +" the target file descriptor of the operation"); + +#define SELECT_EPOLL_UNREGISTER_METHODDEF \ + {"unregister", (PyCFunction)(void(*)(void))select_epoll_unregister, METH_FASTCALL|METH_KEYWORDS, select_epoll_unregister__doc__}, + +static PyObject * +select_epoll_unregister_impl(pyEpoll_Object *self, int fd); + +static PyObject * +select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"fd", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "unregister", 0}; + PyObject *argsbuf[1]; + int 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); + +exit: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll_poll__doc__, +"poll($self, /, timeout=None, maxevents=-1)\n" +"--\n" +"\n" +"Wait for events on the epoll file descriptor.\n" +"\n" +" timeout\n" +" the maximum time to wait in seconds (as float);\n" +" a timeout of None or -1 makes poll wait indefinitely\n" +" maxevents\n" +" the maximum number of events returned; -1 means no limit\n" +"\n" +"Returns a list containing any descriptors that have events to report,\n" +"as a list of (fd, events) 2-tuples."); + +#define SELECT_EPOLL_POLL_METHODDEF \ + {"poll", (PyCFunction)(void(*)(void))select_epoll_poll, METH_FASTCALL|METH_KEYWORDS, select_epoll_poll__doc__}, + +static PyObject * +select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj, + int maxevents); + +static PyObject * +select_epoll_poll(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"timeout", "maxevents", NULL}; + 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; + + 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: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll___enter____doc__, +"__enter__($self, /)\n" +"--\n" +"\n"); + +#define SELECT_EPOLL___ENTER___METHODDEF \ + {"__enter__", (PyCFunction)select_epoll___enter__, METH_NOARGS, select_epoll___enter____doc__}, + +static PyObject * +select_epoll___enter___impl(pyEpoll_Object *self); + +static PyObject * +select_epoll___enter__(pyEpoll_Object *self, PyObject *Py_UNUSED(ignored)) +{ + return select_epoll___enter___impl(self); +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_EPOLL) + +PyDoc_STRVAR(select_epoll___exit____doc__, +"__exit__($self, exc_type=None, exc_value=None, exc_tb=None, /)\n" +"--\n" +"\n"); + +#define SELECT_EPOLL___EXIT___METHODDEF \ + {"__exit__", (PyCFunction)(void(*)(void))select_epoll___exit__, METH_FASTCALL, select_epoll___exit____doc__}, + +static PyObject * +select_epoll___exit___impl(pyEpoll_Object *self, PyObject *exc_type, + PyObject *exc_value, PyObject *exc_tb); + +static PyObject * +select_epoll___exit__(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *exc_type = Py_None; + PyObject *exc_value = Py_None; + PyObject *exc_tb = Py_None; + + if (!_PyArg_CheckPositional("__exit__", nargs, 0, 3)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + exc_type = args[0]; + if (nargs < 2) { + goto skip_optional; + } + exc_value = args[1]; + if (nargs < 3) { + goto skip_optional; + } + exc_tb = args[2]; +skip_optional: + return_value = select_epoll___exit___impl(self, exc_type, exc_value, exc_tb); + +exit: + return return_value; +} + +#endif /* defined(HAVE_EPOLL) */ + +#if defined(HAVE_KQUEUE) + +PyDoc_STRVAR(select_kqueue__doc__, +"kqueue()\n" +"--\n" +"\n" +"Kqueue syscall wrapper.\n" +"\n" +"For example, to start watching a socket for input:\n" +">>> kq = kqueue()\n" +">>> sock = socket()\n" +">>> sock.connect((host, port))\n" +">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)\n" +"\n" +"To wait one second for it to become writeable:\n" +">>> kq.control(None, 1, 1000)\n" +"\n" +"To stop listening:\n" +">>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0)"); + +static PyObject * +select_kqueue_impl(PyTypeObject *type); + +static PyObject * +select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + + if ((type == _selectstate_global->kqueue_queue_Type) && + !_PyArg_NoPositional("kqueue", args)) { + goto exit; + } + if ((type == _selectstate_global->kqueue_queue_Type) && + !_PyArg_NoKeywords("kqueue", kwargs)) { + goto exit; + } + return_value = select_kqueue_impl(type); + +exit: + return return_value; +} + +#endif /* defined(HAVE_KQUEUE) */ + +#if defined(HAVE_KQUEUE) + +PyDoc_STRVAR(select_kqueue_close__doc__, +"close($self, /)\n" +"--\n" +"\n" +"Close the kqueue control file descriptor.\n" +"\n" +"Further operations on the kqueue object will raise an exception."); + +#define SELECT_KQUEUE_CLOSE_METHODDEF \ + {"close", (PyCFunction)select_kqueue_close, METH_NOARGS, select_kqueue_close__doc__}, + +static PyObject * +select_kqueue_close_impl(kqueue_queue_Object *self); + +static PyObject * +select_kqueue_close(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored)) +{ + return select_kqueue_close_impl(self); +} + +#endif /* defined(HAVE_KQUEUE) */ + +#if defined(HAVE_KQUEUE) + +PyDoc_STRVAR(select_kqueue_fileno__doc__, +"fileno($self, /)\n" +"--\n" +"\n" +"Return the kqueue control file descriptor."); + +#define SELECT_KQUEUE_FILENO_METHODDEF \ + {"fileno", (PyCFunction)select_kqueue_fileno, METH_NOARGS, select_kqueue_fileno__doc__}, + +static PyObject * +select_kqueue_fileno_impl(kqueue_queue_Object *self); + +static PyObject * +select_kqueue_fileno(kqueue_queue_Object *self, PyObject *Py_UNUSED(ignored)) +{ + return select_kqueue_fileno_impl(self); +} + +#endif /* defined(HAVE_KQUEUE) */ + +#if defined(HAVE_KQUEUE) + +PyDoc_STRVAR(select_kqueue_fromfd__doc__, +"fromfd($type, fd, /)\n" +"--\n" +"\n" +"Create a kqueue object from a given control fd."); + +#define SELECT_KQUEUE_FROMFD_METHODDEF \ + {"fromfd", (PyCFunction)select_kqueue_fromfd, METH_O|METH_CLASS, select_kqueue_fromfd__doc__}, + +static PyObject * +select_kqueue_fromfd_impl(PyTypeObject *type, int fd); + +static PyObject * +select_kqueue_fromfd(PyTypeObject *type, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = select_kqueue_fromfd_impl(type, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_KQUEUE) */ + +#if defined(HAVE_KQUEUE) + +PyDoc_STRVAR(select_kqueue_control__doc__, +"control($self, changelist, maxevents, timeout=None, /)\n" +"--\n" +"\n" +"Calls the kernel kevent function.\n" +"\n" +" changelist\n" +" Must be an iterable of kevent objects describing the changes to be made\n" +" to the kernel\'s watch list or None.\n" +" maxevents\n" +" The maximum number of events that the kernel will return.\n" +" timeout\n" +" The maximum time to wait in seconds, or else None to wait forever.\n" +" This accepts floats for smaller timeouts, too."); + +#define SELECT_KQUEUE_CONTROL_METHODDEF \ + {"control", (PyCFunction)(void(*)(void))select_kqueue_control, METH_FASTCALL, select_kqueue_control__doc__}, + +static PyObject * +select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist, + int maxevents, PyObject *otimeout); + +static PyObject * +select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *changelist; + int maxevents; + PyObject *otimeout = Py_None; + + if (!_PyArg_CheckPositional("control", nargs, 2, 3)) { + goto exit; + } + changelist = args[0]; + 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; + } + if (nargs < 3) { + goto skip_optional; + } + otimeout = args[2]; +skip_optional: + return_value = select_kqueue_control_impl(self, changelist, maxevents, otimeout); + +exit: + return return_value; +} + +#endif /* defined(HAVE_KQUEUE) */ + +#ifndef SELECT_POLL_REGISTER_METHODDEF + #define SELECT_POLL_REGISTER_METHODDEF +#endif /* !defined(SELECT_POLL_REGISTER_METHODDEF) */ + +#ifndef SELECT_POLL_MODIFY_METHODDEF + #define SELECT_POLL_MODIFY_METHODDEF +#endif /* !defined(SELECT_POLL_MODIFY_METHODDEF) */ + +#ifndef SELECT_POLL_UNREGISTER_METHODDEF + #define SELECT_POLL_UNREGISTER_METHODDEF +#endif /* !defined(SELECT_POLL_UNREGISTER_METHODDEF) */ + +#ifndef SELECT_POLL_POLL_METHODDEF + #define SELECT_POLL_POLL_METHODDEF +#endif /* !defined(SELECT_POLL_POLL_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_REGISTER_METHODDEF + #define SELECT_DEVPOLL_REGISTER_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_REGISTER_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_MODIFY_METHODDEF + #define SELECT_DEVPOLL_MODIFY_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_MODIFY_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_UNREGISTER_METHODDEF + #define SELECT_DEVPOLL_UNREGISTER_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_UNREGISTER_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_POLL_METHODDEF + #define SELECT_DEVPOLL_POLL_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_POLL_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_CLOSE_METHODDEF + #define SELECT_DEVPOLL_CLOSE_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_CLOSE_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_FILENO_METHODDEF + #define SELECT_DEVPOLL_FILENO_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_FILENO_METHODDEF) */ + +#ifndef SELECT_POLL_METHODDEF + #define SELECT_POLL_METHODDEF +#endif /* !defined(SELECT_POLL_METHODDEF) */ + +#ifndef SELECT_DEVPOLL_METHODDEF + #define SELECT_DEVPOLL_METHODDEF +#endif /* !defined(SELECT_DEVPOLL_METHODDEF) */ + +#ifndef SELECT_EPOLL_CLOSE_METHODDEF + #define SELECT_EPOLL_CLOSE_METHODDEF +#endif /* !defined(SELECT_EPOLL_CLOSE_METHODDEF) */ + +#ifndef SELECT_EPOLL_FILENO_METHODDEF + #define SELECT_EPOLL_FILENO_METHODDEF +#endif /* !defined(SELECT_EPOLL_FILENO_METHODDEF) */ + +#ifndef SELECT_EPOLL_FROMFD_METHODDEF + #define SELECT_EPOLL_FROMFD_METHODDEF +#endif /* !defined(SELECT_EPOLL_FROMFD_METHODDEF) */ + +#ifndef SELECT_EPOLL_REGISTER_METHODDEF + #define SELECT_EPOLL_REGISTER_METHODDEF +#endif /* !defined(SELECT_EPOLL_REGISTER_METHODDEF) */ + +#ifndef SELECT_EPOLL_MODIFY_METHODDEF + #define SELECT_EPOLL_MODIFY_METHODDEF +#endif /* !defined(SELECT_EPOLL_MODIFY_METHODDEF) */ + +#ifndef SELECT_EPOLL_UNREGISTER_METHODDEF + #define SELECT_EPOLL_UNREGISTER_METHODDEF +#endif /* !defined(SELECT_EPOLL_UNREGISTER_METHODDEF) */ + +#ifndef SELECT_EPOLL_POLL_METHODDEF + #define SELECT_EPOLL_POLL_METHODDEF +#endif /* !defined(SELECT_EPOLL_POLL_METHODDEF) */ + +#ifndef SELECT_EPOLL___ENTER___METHODDEF + #define SELECT_EPOLL___ENTER___METHODDEF +#endif /* !defined(SELECT_EPOLL___ENTER___METHODDEF) */ + +#ifndef SELECT_EPOLL___EXIT___METHODDEF + #define SELECT_EPOLL___EXIT___METHODDEF +#endif /* !defined(SELECT_EPOLL___EXIT___METHODDEF) */ + +#ifndef SELECT_KQUEUE_CLOSE_METHODDEF + #define SELECT_KQUEUE_CLOSE_METHODDEF +#endif /* !defined(SELECT_KQUEUE_CLOSE_METHODDEF) */ + +#ifndef SELECT_KQUEUE_FILENO_METHODDEF + #define SELECT_KQUEUE_FILENO_METHODDEF +#endif /* !defined(SELECT_KQUEUE_FILENO_METHODDEF) */ + +#ifndef SELECT_KQUEUE_FROMFD_METHODDEF + #define SELECT_KQUEUE_FROMFD_METHODDEF +#endif /* !defined(SELECT_KQUEUE_FROMFD_METHODDEF) */ + +#ifndef SELECT_KQUEUE_CONTROL_METHODDEF + #define SELECT_KQUEUE_CONTROL_METHODDEF +#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ +/*[clinic end generated code: output=ef42c3485a8fe3a0 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/sha1module.c.h b/contrib/tools/python3/src/Modules/clinic/sha1module.c.h index fc37b1ab88..5a464582d2 100644 --- a/contrib/tools/python3/src/Modules/clinic/sha1module.c.h +++ b/contrib/tools/python3/src/Modules/clinic/sha1module.c.h @@ -66,53 +66,53 @@ PyDoc_STRVAR(SHA1Type_update__doc__, {"update", (PyCFunction)SHA1Type_update, METH_O, SHA1Type_update__doc__}, PyDoc_STRVAR(_sha1_sha1__doc__, -"sha1($module, /, string=b\'\', *, usedforsecurity=True)\n" +"sha1($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA1 hash object; optionally initialized with a string."); #define _SHA1_SHA1_METHODDEF \ - {"sha1", (PyCFunction)(void(*)(void))_sha1_sha1, METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__}, + {"sha1", (PyCFunction)(void(*)(void))_sha1_sha1, METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__}, static PyObject * -_sha1_sha1_impl(PyObject *module, PyObject *string, int usedforsecurity); +_sha1_sha1_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sha1", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha1", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _sha1_sha1_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _sha1_sha1_impl(module, string, usedforsecurity); exit: return return_value; } -/*[clinic end generated code: output=3ddd637ae17e14b3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3ddd637ae17e14b3 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/sha256module.c.h b/contrib/tools/python3/src/Modules/clinic/sha256module.c.h index 2a788ea984..8e6e7c64da 100644 --- a/contrib/tools/python3/src/Modules/clinic/sha256module.c.h +++ b/contrib/tools/python3/src/Modules/clinic/sha256module.c.h @@ -66,104 +66,104 @@ PyDoc_STRVAR(SHA256Type_update__doc__, {"update", (PyCFunction)SHA256Type_update, METH_O, SHA256Type_update__doc__}, PyDoc_STRVAR(_sha256_sha256__doc__, -"sha256($module, /, string=b\'\', *, usedforsecurity=True)\n" +"sha256($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-256 hash object; optionally initialized with a string."); #define _SHA256_SHA256_METHODDEF \ - {"sha256", (PyCFunction)(void(*)(void))_sha256_sha256, METH_FASTCALL|METH_KEYWORDS, _sha256_sha256__doc__}, + {"sha256", (PyCFunction)(void(*)(void))_sha256_sha256, METH_FASTCALL|METH_KEYWORDS, _sha256_sha256__doc__}, static PyObject * -_sha256_sha256_impl(PyObject *module, PyObject *string, int usedforsecurity); +_sha256_sha256_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _sha256_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sha256", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha256", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _sha256_sha256_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _sha256_sha256_impl(module, string, usedforsecurity); exit: return return_value; } PyDoc_STRVAR(_sha256_sha224__doc__, -"sha224($module, /, string=b\'\', *, usedforsecurity=True)\n" +"sha224($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-224 hash object; optionally initialized with a string."); #define _SHA256_SHA224_METHODDEF \ - {"sha224", (PyCFunction)(void(*)(void))_sha256_sha224, METH_FASTCALL|METH_KEYWORDS, _sha256_sha224__doc__}, + {"sha224", (PyCFunction)(void(*)(void))_sha256_sha224, METH_FASTCALL|METH_KEYWORDS, _sha256_sha224__doc__}, static PyObject * -_sha256_sha224_impl(PyObject *module, PyObject *string, int usedforsecurity); +_sha256_sha224_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _sha256_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sha224", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha224", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_kwonly: - return_value = _sha256_sha224_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _sha256_sha224_impl(module, string, usedforsecurity); exit: return return_value; } -/*[clinic end generated code: output=c8cca8adbe72ec9a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c8cca8adbe72ec9a input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/sha512module.c.h b/contrib/tools/python3/src/Modules/clinic/sha512module.c.h index b8185b62bb..480202dca9 100644 --- a/contrib/tools/python3/src/Modules/clinic/sha512module.c.h +++ b/contrib/tools/python3/src/Modules/clinic/sha512module.c.h @@ -66,104 +66,104 @@ PyDoc_STRVAR(SHA512Type_update__doc__, {"update", (PyCFunction)SHA512Type_update, METH_O, SHA512Type_update__doc__}, PyDoc_STRVAR(_sha512_sha512__doc__, -"sha512($module, /, string=b\'\', *, usedforsecurity=True)\n" +"sha512($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-512 hash object; optionally initialized with a string."); #define _SHA512_SHA512_METHODDEF \ - {"sha512", (PyCFunction)(void(*)(void))_sha512_sha512, METH_FASTCALL|METH_KEYWORDS, _sha512_sha512__doc__}, + {"sha512", (PyCFunction)(void(*)(void))_sha512_sha512, METH_FASTCALL|METH_KEYWORDS, _sha512_sha512__doc__}, static PyObject * -_sha512_sha512_impl(PyObject *module, PyObject *string, int usedforsecurity); +_sha512_sha512_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _sha512_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sha512", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha512", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = _sha512_sha512_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _sha512_sha512_impl(module, string, usedforsecurity); exit: return return_value; } PyDoc_STRVAR(_sha512_sha384__doc__, -"sha384($module, /, string=b\'\', *, usedforsecurity=True)\n" +"sha384($module, /, string=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-384 hash object; optionally initialized with a string."); #define _SHA512_SHA384_METHODDEF \ - {"sha384", (PyCFunction)(void(*)(void))_sha512_sha384, METH_FASTCALL|METH_KEYWORDS, _sha512_sha384__doc__}, + {"sha384", (PyCFunction)(void(*)(void))_sha512_sha384, METH_FASTCALL|METH_KEYWORDS, _sha512_sha384__doc__}, static PyObject * -_sha512_sha384_impl(PyObject *module, PyObject *string, int usedforsecurity); +_sha512_sha384_impl(PyObject *module, PyObject *string, int usedforsecurity); static PyObject * _sha512_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sha384", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static const char * const _keywords[] = {"string", "usedforsecurity", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha384", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - int usedforsecurity = 1; + int usedforsecurity = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - string = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } -skip_optional_pos: - if (!noptargs) { - goto skip_optional_kwonly; - } - usedforsecurity = PyObject_IsTrue(args[1]); - if (usedforsecurity < 0) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } -skip_optional_kwonly: - return_value = _sha512_sha384_impl(module, string, usedforsecurity); + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + string = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + usedforsecurity = PyObject_IsTrue(args[1]); + if (usedforsecurity < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _sha512_sha384_impl(module, string, usedforsecurity); exit: return return_value; } -/*[clinic end generated code: output=bbfa72d8703c82b5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bbfa72d8703c82b5 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/signalmodule.c.h b/contrib/tools/python3/src/Modules/clinic/signalmodule.c.h index 0fb25d5640..3361ce3b1d 100644 --- a/contrib/tools/python3/src/Modules/clinic/signalmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/signalmodule.c.h @@ -23,15 +23,15 @@ signal_alarm(PyObject *module, PyObject *arg) int seconds; long _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - seconds = _PyLong_AsInt(arg); - if (seconds == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + seconds = _PyLong_AsInt(arg); + if (seconds == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = signal_alarm_impl(module, seconds); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -66,39 +66,39 @@ signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_PAUSE) */ -PyDoc_STRVAR(signal_raise_signal__doc__, -"raise_signal($module, signalnum, /)\n" -"--\n" -"\n" -"Send a signal to the executing process."); - -#define SIGNAL_RAISE_SIGNAL_METHODDEF \ - {"raise_signal", (PyCFunction)signal_raise_signal, METH_O, signal_raise_signal__doc__}, - -static PyObject * -signal_raise_signal_impl(PyObject *module, int signalnum); - -static PyObject * -signal_raise_signal(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int signalnum; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(arg); - if (signalnum == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = signal_raise_signal_impl(module, signalnum); - -exit: - return return_value; -} - +PyDoc_STRVAR(signal_raise_signal__doc__, +"raise_signal($module, signalnum, /)\n" +"--\n" +"\n" +"Send a signal to the executing process."); + +#define SIGNAL_RAISE_SIGNAL_METHODDEF \ + {"raise_signal", (PyCFunction)signal_raise_signal, METH_O, signal_raise_signal__doc__}, + +static PyObject * +signal_raise_signal_impl(PyObject *module, int signalnum); + +static PyObject * +signal_raise_signal(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int signalnum; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(arg); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = signal_raise_signal_impl(module, signalnum); + +exit: + return return_value; +} + PyDoc_STRVAR(signal_signal__doc__, "signal($module, signalnum, handler, /)\n" "--\n" @@ -113,7 +113,7 @@ PyDoc_STRVAR(signal_signal__doc__, "the first is the signal number, the second is the interrupted stack frame."); #define SIGNAL_SIGNAL_METHODDEF \ - {"signal", (PyCFunction)(void(*)(void))signal_signal, METH_FASTCALL, signal_signal__doc__}, + {"signal", (PyCFunction)(void(*)(void))signal_signal, METH_FASTCALL, signal_signal__doc__}, static PyObject * signal_signal_impl(PyObject *module, int signalnum, PyObject *handler); @@ -125,19 +125,19 @@ signal_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int signalnum; PyObject *handler; - if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(args[0]); - if (signalnum == -1 && PyErr_Occurred()) { + if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) { goto exit; } - handler = args[1]; + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(args[0]); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + handler = args[1]; return_value = signal_signal_impl(module, signalnum, handler); exit: @@ -168,57 +168,57 @@ signal_getsignal(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int signalnum; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(arg); - if (signalnum == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + signalnum = _PyLong_AsInt(arg); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } return_value = signal_getsignal_impl(module, signalnum); exit: return return_value; } -PyDoc_STRVAR(signal_strsignal__doc__, -"strsignal($module, signalnum, /)\n" -"--\n" -"\n" -"Return the system description of the given signal.\n" -"\n" -"The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n" -"Returns None if the signal is not recognized."); - -#define SIGNAL_STRSIGNAL_METHODDEF \ - {"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__}, - -static PyObject * -signal_strsignal_impl(PyObject *module, int signalnum); - -static PyObject * -signal_strsignal(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int signalnum; - - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(arg); - if (signalnum == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = signal_strsignal_impl(module, signalnum); - -exit: - return return_value; -} - +PyDoc_STRVAR(signal_strsignal__doc__, +"strsignal($module, signalnum, /)\n" +"--\n" +"\n" +"Return the system description of the given signal.\n" +"\n" +"The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n" +"Returns None if the signal is not recognized."); + +#define SIGNAL_STRSIGNAL_METHODDEF \ + {"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__}, + +static PyObject * +signal_strsignal_impl(PyObject *module, int signalnum); + +static PyObject * +signal_strsignal(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int signalnum; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(arg); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = signal_strsignal_impl(module, signalnum); + +exit: + return return_value; +} + #if defined(HAVE_SIGINTERRUPT) PyDoc_STRVAR(signal_siginterrupt__doc__, @@ -231,7 +231,7 @@ PyDoc_STRVAR(signal_siginterrupt__doc__, "signal sig, else system calls will be interrupted."); #define SIGNAL_SIGINTERRUPT_METHODDEF \ - {"siginterrupt", (PyCFunction)(void(*)(void))signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, + {"siginterrupt", (PyCFunction)(void(*)(void))signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, static PyObject * signal_siginterrupt_impl(PyObject *module, int signalnum, int flag); @@ -243,27 +243,27 @@ signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int signalnum; int flag; - if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(args[0]); - if (signalnum == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flag = _PyLong_AsInt(args[1]); - if (flag == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(args[0]); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flag = _PyLong_AsInt(args[1]); + if (flag == -1 && PyErr_Occurred()) { + goto exit; + } return_value = signal_siginterrupt_impl(module, signalnum, flag); exit: @@ -286,7 +286,7 @@ PyDoc_STRVAR(signal_setitimer__doc__, "Returns old values as a tuple: (delay, interval)."); #define SIGNAL_SETITIMER_METHODDEF \ - {"setitimer", (PyCFunction)(void(*)(void))signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, + {"setitimer", (PyCFunction)(void(*)(void))signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, static PyObject * signal_setitimer_impl(PyObject *module, int which, PyObject *seconds, @@ -300,24 +300,24 @@ signal_setitimer(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *seconds; PyObject *interval = NULL; - if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - which = _PyLong_AsInt(args[0]); - if (which == -1 && PyErr_Occurred()) { - goto exit; - } - seconds = args[1]; - if (nargs < 3) { - goto skip_optional; - } - interval = args[2]; -skip_optional: + if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + which = _PyLong_AsInt(args[0]); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } + seconds = args[1]; + if (nargs < 3) { + goto skip_optional; + } + interval = args[2]; +skip_optional: return_value = signal_setitimer_impl(module, which, seconds, interval); exit: @@ -346,15 +346,15 @@ signal_getitimer(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int which; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - which = _PyLong_AsInt(arg); - if (which == -1 && PyErr_Occurred()) { + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + which = _PyLong_AsInt(arg); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } return_value = signal_getitimer_impl(module, which); exit: @@ -363,7 +363,7 @@ exit: #endif /* defined(HAVE_GETITIMER) */ -#if defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK) +#if defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK) PyDoc_STRVAR(signal_pthread_sigmask__doc__, "pthread_sigmask($module, how, mask, /)\n" @@ -372,42 +372,42 @@ PyDoc_STRVAR(signal_pthread_sigmask__doc__, "Fetch and/or change the signal mask of the calling thread."); #define SIGNAL_PTHREAD_SIGMASK_METHODDEF \ - {"pthread_sigmask", (PyCFunction)(void(*)(void))signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, + {"pthread_sigmask", (PyCFunction)(void(*)(void))signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, static PyObject * -signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask); +signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask); static PyObject * signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int how; - sigset_t mask; - - if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - how = _PyLong_AsInt(args[0]); - if (how == -1 && PyErr_Occurred()) { - goto exit; - } - if (!_Py_Sigset_Converter(args[1], &mask)) { - goto exit; - } + sigset_t mask; + + if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + how = _PyLong_AsInt(args[0]); + if (how == -1 && PyErr_Occurred()) { + goto exit; + } + if (!_Py_Sigset_Converter(args[1], &mask)) { + goto exit; + } return_value = signal_pthread_sigmask_impl(module, how, mask); exit: return return_value; } -#endif /* defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK) */ +#endif /* defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK) */ -#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING) +#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING) PyDoc_STRVAR(signal_sigpending__doc__, "sigpending($module, /)\n" @@ -430,9 +430,9 @@ signal_sigpending(PyObject *module, PyObject *Py_UNUSED(ignored)) return signal_sigpending_impl(module); } -#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING) */ +#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING) */ -#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT) +#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT) PyDoc_STRVAR(signal_sigwait__doc__, "sigwait($module, sigset, /)\n" @@ -447,52 +447,52 @@ PyDoc_STRVAR(signal_sigwait__doc__, #define SIGNAL_SIGWAIT_METHODDEF \ {"sigwait", (PyCFunction)signal_sigwait, METH_O, signal_sigwait__doc__}, -static PyObject * -signal_sigwait_impl(PyObject *module, sigset_t sigset); - -static PyObject * -signal_sigwait(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - sigset_t sigset; - - if (!_Py_Sigset_Converter(arg, &sigset)) { - goto exit; - } - return_value = signal_sigwait_impl(module, sigset); - -exit: - return return_value; -} - -#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT) */ - -#if ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)) - -PyDoc_STRVAR(signal_valid_signals__doc__, -"valid_signals($module, /)\n" -"--\n" -"\n" -"Return a set of valid signal numbers on this platform.\n" -"\n" -"The signal numbers returned by this function can be safely passed to\n" -"functions like `pthread_sigmask`."); - -#define SIGNAL_VALID_SIGNALS_METHODDEF \ - {"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__}, - -static PyObject * -signal_valid_signals_impl(PyObject *module); - -static PyObject * -signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return signal_valid_signals_impl(module); -} - -#endif /* ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)) */ - -#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO) +static PyObject * +signal_sigwait_impl(PyObject *module, sigset_t sigset); + +static PyObject * +signal_sigwait(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + sigset_t sigset; + + if (!_Py_Sigset_Converter(arg, &sigset)) { + goto exit; + } + return_value = signal_sigwait_impl(module, sigset); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT) */ + +#if ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)) + +PyDoc_STRVAR(signal_valid_signals__doc__, +"valid_signals($module, /)\n" +"--\n" +"\n" +"Return a set of valid signal numbers on this platform.\n" +"\n" +"The signal numbers returned by this function can be safely passed to\n" +"functions like `pthread_sigmask`."); + +#define SIGNAL_VALID_SIGNALS_METHODDEF \ + {"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__}, + +static PyObject * +signal_valid_signals_impl(PyObject *module); + +static PyObject * +signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return signal_valid_signals_impl(module); +} + +#endif /* ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)) */ + +#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO) PyDoc_STRVAR(signal_sigwaitinfo__doc__, "sigwaitinfo($module, sigset, /)\n" @@ -505,27 +505,27 @@ PyDoc_STRVAR(signal_sigwaitinfo__doc__, #define SIGNAL_SIGWAITINFO_METHODDEF \ {"sigwaitinfo", (PyCFunction)signal_sigwaitinfo, METH_O, signal_sigwaitinfo__doc__}, -static PyObject * -signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset); - -static PyObject * -signal_sigwaitinfo(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - sigset_t sigset; - - if (!_Py_Sigset_Converter(arg, &sigset)) { - goto exit; - } - return_value = signal_sigwaitinfo_impl(module, sigset); - -exit: - return return_value; -} - -#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO) */ - -#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT) +static PyObject * +signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset); + +static PyObject * +signal_sigwaitinfo(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + sigset_t sigset; + + if (!_Py_Sigset_Converter(arg, &sigset)) { + goto exit; + } + return_value = signal_sigwaitinfo_impl(module, sigset); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO) */ + +#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT) PyDoc_STRVAR(signal_sigtimedwait__doc__, "sigtimedwait($module, sigset, timeout, /)\n" @@ -536,33 +536,33 @@ PyDoc_STRVAR(signal_sigtimedwait__doc__, "The timeout is specified in seconds, with floating point numbers allowed."); #define SIGNAL_SIGTIMEDWAIT_METHODDEF \ - {"sigtimedwait", (PyCFunction)(void(*)(void))signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, + {"sigtimedwait", (PyCFunction)(void(*)(void))signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, static PyObject * -signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, +signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, PyObject *timeout_obj); static PyObject * signal_sigtimedwait(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - sigset_t sigset; + sigset_t sigset; PyObject *timeout_obj; - if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) { goto exit; } - if (!_Py_Sigset_Converter(args[0], &sigset)) { - goto exit; - } - timeout_obj = args[1]; + if (!_Py_Sigset_Converter(args[0], &sigset)) { + goto exit; + } + timeout_obj = args[1]; return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj); exit: return return_value; } -#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT) */ +#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT) */ #if defined(HAVE_PTHREAD_KILL) @@ -573,7 +573,7 @@ PyDoc_STRVAR(signal_pthread_kill__doc__, "Send a signal to a thread."); #define SIGNAL_PTHREAD_KILL_METHODDEF \ - {"pthread_kill", (PyCFunction)(void(*)(void))signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, + {"pthread_kill", (PyCFunction)(void(*)(void))signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, static PyObject * signal_pthread_kill_impl(PyObject *module, unsigned long thread_id, @@ -586,23 +586,23 @@ signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs) unsigned long thread_id; int signalnum; - if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) { - goto exit; - } - if (!PyLong_Check(args[0])) { - _PyArg_BadArgument("pthread_kill", "argument 1", "int", args[0]); - goto exit; - } - thread_id = PyLong_AsUnsignedLongMask(args[0]); - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(args[1]); - if (signalnum == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) { + goto exit; + } + if (!PyLong_Check(args[0])) { + _PyArg_BadArgument("pthread_kill", "argument 1", "int", args[0]); + goto exit; + } + thread_id = PyLong_AsUnsignedLongMask(args[0]); + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(args[1]); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } return_value = signal_pthread_kill_impl(module, thread_id, signalnum); exit: @@ -611,76 +611,76 @@ exit: #endif /* defined(HAVE_PTHREAD_KILL) */ -#if (defined(__linux__) && defined(__NR_pidfd_send_signal)) - -PyDoc_STRVAR(signal_pidfd_send_signal__doc__, -"pidfd_send_signal($module, pidfd, signalnum, siginfo=None, flags=0, /)\n" -"--\n" -"\n" -"Send a signal to a process referred to by a pid file descriptor."); - -#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF \ - {"pidfd_send_signal", (PyCFunction)(void(*)(void))signal_pidfd_send_signal, METH_FASTCALL, signal_pidfd_send_signal__doc__}, - -static PyObject * -signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum, - PyObject *siginfo, int flags); - -static PyObject * -signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int pidfd; - int signalnum; - PyObject *siginfo = Py_None; - int flags = 0; - - if (!_PyArg_CheckPositional("pidfd_send_signal", nargs, 2, 4)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - pidfd = _PyLong_AsInt(args[0]); - if (pidfd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - signalnum = _PyLong_AsInt(args[1]); - if (signalnum == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - siginfo = args[2]; - if (nargs < 4) { - goto skip_optional; - } - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[3]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = signal_pidfd_send_signal_impl(module, pidfd, signalnum, siginfo, flags); - -exit: - return return_value; -} - -#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal)) */ - +#if (defined(__linux__) && defined(__NR_pidfd_send_signal)) + +PyDoc_STRVAR(signal_pidfd_send_signal__doc__, +"pidfd_send_signal($module, pidfd, signalnum, siginfo=None, flags=0, /)\n" +"--\n" +"\n" +"Send a signal to a process referred to by a pid file descriptor."); + +#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF \ + {"pidfd_send_signal", (PyCFunction)(void(*)(void))signal_pidfd_send_signal, METH_FASTCALL, signal_pidfd_send_signal__doc__}, + +static PyObject * +signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum, + PyObject *siginfo, int flags); + +static PyObject * +signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int pidfd; + int signalnum; + PyObject *siginfo = Py_None; + int flags = 0; + + if (!_PyArg_CheckPositional("pidfd_send_signal", nargs, 2, 4)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + pidfd = _PyLong_AsInt(args[0]); + if (pidfd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(args[1]); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + siginfo = args[2]; + if (nargs < 4) { + goto skip_optional; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = signal_pidfd_send_signal_impl(module, pidfd, signalnum, siginfo, flags); + +exit: + return return_value; +} + +#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal)) */ + #ifndef SIGNAL_ALARM_METHODDEF #define SIGNAL_ALARM_METHODDEF #endif /* !defined(SIGNAL_ALARM_METHODDEF) */ @@ -713,10 +713,10 @@ exit: #define SIGNAL_SIGWAIT_METHODDEF #endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */ -#ifndef SIGNAL_VALID_SIGNALS_METHODDEF - #define SIGNAL_VALID_SIGNALS_METHODDEF -#endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */ - +#ifndef SIGNAL_VALID_SIGNALS_METHODDEF + #define SIGNAL_VALID_SIGNALS_METHODDEF +#endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */ + #ifndef SIGNAL_SIGWAITINFO_METHODDEF #define SIGNAL_SIGWAITINFO_METHODDEF #endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */ @@ -728,8 +728,8 @@ exit: #ifndef SIGNAL_PTHREAD_KILL_METHODDEF #define SIGNAL_PTHREAD_KILL_METHODDEF #endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */ - -#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF - #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF -#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */ -/*[clinic end generated code: output=3c8b80f14df17563 input=a9049054013a1b77]*/ + +#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF + #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF +#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */ +/*[clinic end generated code: output=3c8b80f14df17563 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/spwdmodule.c.h b/contrib/tools/python3/src/Modules/clinic/spwdmodule.c.h index 411d2344e1..159f982ecc 100644 --- a/contrib/tools/python3/src/Modules/clinic/spwdmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/spwdmodule.c.h @@ -24,14 +24,14 @@ spwd_getspnam(PyObject *module, PyObject *arg_) PyObject *return_value = NULL; PyObject *arg; - if (!PyUnicode_Check(arg_)) { - _PyArg_BadArgument("getspnam", "argument", "str", arg_); + if (!PyUnicode_Check(arg_)) { + _PyArg_BadArgument("getspnam", "argument", "str", arg_); goto exit; } - if (PyUnicode_READY(arg_) == -1) { - goto exit; - } - arg = arg_; + if (PyUnicode_READY(arg_) == -1) { + goto exit; + } + arg = arg_; return_value = spwd_getspnam_impl(module, arg); exit: @@ -71,4 +71,4 @@ spwd_getspall(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef SPWD_GETSPALL_METHODDEF #define SPWD_GETSPALL_METHODDEF #endif /* !defined(SPWD_GETSPALL_METHODDEF) */ -/*[clinic end generated code: output=eec8d0bedcd312e5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eec8d0bedcd312e5 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/symtablemodule.c.h b/contrib/tools/python3/src/Modules/clinic/symtablemodule.c.h index 4a17f130ac..a46d0b4032 100644 --- a/contrib/tools/python3/src/Modules/clinic/symtablemodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/symtablemodule.c.h @@ -3,49 +3,49 @@ preserve [clinic start generated code]*/ PyDoc_STRVAR(_symtable_symtable__doc__, -"symtable($module, source, filename, startstr, /)\n" +"symtable($module, source, filename, startstr, /)\n" "--\n" "\n" "Return symbol and scope dictionaries used internally by compiler."); #define _SYMTABLE_SYMTABLE_METHODDEF \ - {"symtable", (PyCFunction)(void(*)(void))_symtable_symtable, METH_FASTCALL, _symtable_symtable__doc__}, + {"symtable", (PyCFunction)(void(*)(void))_symtable_symtable, METH_FASTCALL, _symtable_symtable__doc__}, static PyObject * -_symtable_symtable_impl(PyObject *module, PyObject *source, +_symtable_symtable_impl(PyObject *module, PyObject *source, PyObject *filename, const char *startstr); static PyObject * _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *source; + PyObject *source; PyObject *filename; const char *startstr; - if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) { + if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) { goto exit; } - source = args[0]; - if (!PyUnicode_FSDecoder(args[1], &filename)) { - goto exit; - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("symtable", "argument 3", "str", args[2]); - goto exit; - } - Py_ssize_t startstr_length; - startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length); - if (startstr == NULL) { - goto exit; - } - if (strlen(startstr) != (size_t)startstr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - return_value = _symtable_symtable_impl(module, source, filename, startstr); + source = args[0]; + if (!PyUnicode_FSDecoder(args[1], &filename)) { + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("symtable", "argument 3", "str", args[2]); + goto exit; + } + Py_ssize_t startstr_length; + startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length); + if (startstr == NULL) { + goto exit; + } + if (strlen(startstr) != (size_t)startstr_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = _symtable_symtable_impl(module, source, filename, startstr); exit: return return_value; } -/*[clinic end generated code: output=a12f75cdbdf4e52a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a12f75cdbdf4e52a input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/unicodedata.c.h b/contrib/tools/python3/src/Modules/clinic/unicodedata.c.h index 4251db2edc..30280012ed 100644 --- a/contrib/tools/python3/src/Modules/clinic/unicodedata.c.h +++ b/contrib/tools/python3/src/Modules/clinic/unicodedata.c.h @@ -3,7 +3,7 @@ preserve [clinic start generated code]*/ PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, -"decimal($self, chr, default=<unrepresentable>, /)\n" +"decimal($self, chr, default=<unrepresentable>, /)\n" "--\n" "\n" "Converts a Unicode character into its equivalent decimal value.\n" @@ -13,7 +13,7 @@ PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_DECIMAL_METHODDEF \ - {"decimal", (PyCFunction)(void(*)(void))unicodedata_UCD_decimal, METH_FASTCALL, unicodedata_UCD_decimal__doc__}, + {"decimal", (PyCFunction)(void(*)(void))unicodedata_UCD_decimal, METH_FASTCALL, unicodedata_UCD_decimal__doc__}, static PyObject * unicodedata_UCD_decimal_impl(PyObject *self, int chr, @@ -26,26 +26,26 @@ unicodedata_UCD_decimal(PyObject *self, PyObject *const *args, Py_ssize_t nargs) int chr; PyObject *default_value = NULL; - if (!_PyArg_CheckPositional("decimal", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0])) { - goto exit; - } - if (PyUnicode_GET_LENGTH(args[0]) != 1) { - _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]); - goto exit; - } - chr = PyUnicode_READ_CHAR(args[0], 0); - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + if (!_PyArg_CheckPositional("decimal", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0])) { + goto exit; + } + if (PyUnicode_GET_LENGTH(args[0]) != 1) { + _PyArg_BadArgument("decimal", "argument 1", "a unicode character", args[0]); + goto exit; + } + chr = PyUnicode_READ_CHAR(args[0], 0); + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = unicodedata_UCD_decimal_impl(self, chr, default_value); exit: @@ -53,7 +53,7 @@ exit: } PyDoc_STRVAR(unicodedata_UCD_digit__doc__, -"digit($self, chr, default=<unrepresentable>, /)\n" +"digit($self, chr, default=<unrepresentable>, /)\n" "--\n" "\n" "Converts a Unicode character into its equivalent digit value.\n" @@ -63,7 +63,7 @@ PyDoc_STRVAR(unicodedata_UCD_digit__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_DIGIT_METHODDEF \ - {"digit", (PyCFunction)(void(*)(void))unicodedata_UCD_digit, METH_FASTCALL, unicodedata_UCD_digit__doc__}, + {"digit", (PyCFunction)(void(*)(void))unicodedata_UCD_digit, METH_FASTCALL, unicodedata_UCD_digit__doc__}, static PyObject * unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value); @@ -75,26 +75,26 @@ unicodedata_UCD_digit(PyObject *self, PyObject *const *args, Py_ssize_t nargs) int chr; PyObject *default_value = NULL; - if (!_PyArg_CheckPositional("digit", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0])) { - goto exit; - } - if (PyUnicode_GET_LENGTH(args[0]) != 1) { - _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]); - goto exit; - } - chr = PyUnicode_READ_CHAR(args[0], 0); - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + if (!_PyArg_CheckPositional("digit", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0])) { + goto exit; + } + if (PyUnicode_GET_LENGTH(args[0]) != 1) { + _PyArg_BadArgument("digit", "argument 1", "a unicode character", args[0]); + goto exit; + } + chr = PyUnicode_READ_CHAR(args[0], 0); + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = unicodedata_UCD_digit_impl(self, chr, default_value); exit: @@ -102,7 +102,7 @@ exit: } PyDoc_STRVAR(unicodedata_UCD_numeric__doc__, -"numeric($self, chr, default=<unrepresentable>, /)\n" +"numeric($self, chr, default=<unrepresentable>, /)\n" "--\n" "\n" "Converts a Unicode character into its equivalent numeric value.\n" @@ -112,7 +112,7 @@ PyDoc_STRVAR(unicodedata_UCD_numeric__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_NUMERIC_METHODDEF \ - {"numeric", (PyCFunction)(void(*)(void))unicodedata_UCD_numeric, METH_FASTCALL, unicodedata_UCD_numeric__doc__}, + {"numeric", (PyCFunction)(void(*)(void))unicodedata_UCD_numeric, METH_FASTCALL, unicodedata_UCD_numeric__doc__}, static PyObject * unicodedata_UCD_numeric_impl(PyObject *self, int chr, @@ -125,26 +125,26 @@ unicodedata_UCD_numeric(PyObject *self, PyObject *const *args, Py_ssize_t nargs) int chr; PyObject *default_value = NULL; - if (!_PyArg_CheckPositional("numeric", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0])) { - goto exit; - } - if (PyUnicode_GET_LENGTH(args[0]) != 1) { - _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]); - goto exit; - } - chr = PyUnicode_READ_CHAR(args[0], 0); - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + if (!_PyArg_CheckPositional("numeric", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0])) { + goto exit; + } + if (PyUnicode_GET_LENGTH(args[0]) != 1) { + _PyArg_BadArgument("numeric", "argument 1", "a unicode character", args[0]); + goto exit; + } + chr = PyUnicode_READ_CHAR(args[0], 0); + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = unicodedata_UCD_numeric_impl(self, chr, default_value); exit: @@ -169,18 +169,18 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("category", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("category", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("category", "argument", "a unicode character", arg); goto exit; } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("category", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_category_impl(self, chr); exit: @@ -207,18 +207,18 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg); goto exit; } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg); - goto exit; - } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("bidirectional", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_bidirectional_impl(self, chr); exit: @@ -246,18 +246,18 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg) int chr; int _return_value; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("combining", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("combining", "argument", "a unicode character", arg); goto exit; } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("combining", "argument", "a unicode character", arg); - goto exit; - } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("combining", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); _return_value = unicodedata_UCD_combining_impl(self, chr); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -290,18 +290,18 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg) int chr; int _return_value; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg); goto exit; } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("mirrored", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); _return_value = unicodedata_UCD_mirrored_impl(self, chr); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -330,18 +330,18 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg); goto exit; } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg); - goto exit; - } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("east_asian_width", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_east_asian_width_impl(self, chr); exit: @@ -368,71 +368,71 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg); goto exit; } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg); - goto exit; - } - chr = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("decomposition", "argument", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_decomposition_impl(self, chr); exit: return return_value; } -PyDoc_STRVAR(unicodedata_UCD_is_normalized__doc__, -"is_normalized($self, form, unistr, /)\n" -"--\n" -"\n" -"Return whether the Unicode string unistr is in the normal form \'form\'.\n" -"\n" -"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); - -#define UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF \ - {"is_normalized", (PyCFunction)(void(*)(void))unicodedata_UCD_is_normalized, METH_FASTCALL, unicodedata_UCD_is_normalized__doc__}, - -static PyObject * -unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form, - PyObject *input); - -static PyObject * -unicodedata_UCD_is_normalized(PyObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *form; - PyObject *input; - - if (!_PyArg_CheckPositional("is_normalized", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("is_normalized", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - form = args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("is_normalized", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - input = args[1]; - return_value = unicodedata_UCD_is_normalized_impl(self, form, input); - -exit: - return return_value; -} - +PyDoc_STRVAR(unicodedata_UCD_is_normalized__doc__, +"is_normalized($self, form, unistr, /)\n" +"--\n" +"\n" +"Return whether the Unicode string unistr is in the normal form \'form\'.\n" +"\n" +"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); + +#define UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF \ + {"is_normalized", (PyCFunction)(void(*)(void))unicodedata_UCD_is_normalized, METH_FASTCALL, unicodedata_UCD_is_normalized__doc__}, + +static PyObject * +unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form, + PyObject *input); + +static PyObject * +unicodedata_UCD_is_normalized(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *form; + PyObject *input; + + if (!_PyArg_CheckPositional("is_normalized", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("is_normalized", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + form = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("is_normalized", "argument 2", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + input = args[1]; + return_value = unicodedata_UCD_is_normalized_impl(self, form, input); + +exit: + return return_value; +} + PyDoc_STRVAR(unicodedata_UCD_normalize__doc__, "normalize($self, form, unistr, /)\n" "--\n" @@ -442,38 +442,38 @@ PyDoc_STRVAR(unicodedata_UCD_normalize__doc__, "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); #define UNICODEDATA_UCD_NORMALIZE_METHODDEF \ - {"normalize", (PyCFunction)(void(*)(void))unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__}, + {"normalize", (PyCFunction)(void(*)(void))unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__}, static PyObject * -unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form, +unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form, PyObject *input); static PyObject * unicodedata_UCD_normalize(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *form; + PyObject *form; PyObject *input; - if (!_PyArg_CheckPositional("normalize", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("normalize", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - form = args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("normalize", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - input = args[1]; + if (!_PyArg_CheckPositional("normalize", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("normalize", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + form = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("normalize", "argument 2", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + input = args[1]; return_value = unicodedata_UCD_normalize_impl(self, form, input); exit: @@ -481,7 +481,7 @@ exit: } PyDoc_STRVAR(unicodedata_UCD_name__doc__, -"name($self, chr, default=<unrepresentable>, /)\n" +"name($self, chr, default=<unrepresentable>, /)\n" "--\n" "\n" "Returns the name assigned to the character chr as a string.\n" @@ -490,7 +490,7 @@ PyDoc_STRVAR(unicodedata_UCD_name__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_NAME_METHODDEF \ - {"name", (PyCFunction)(void(*)(void))unicodedata_UCD_name, METH_FASTCALL, unicodedata_UCD_name__doc__}, + {"name", (PyCFunction)(void(*)(void))unicodedata_UCD_name, METH_FASTCALL, unicodedata_UCD_name__doc__}, static PyObject * unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value); @@ -502,26 +502,26 @@ unicodedata_UCD_name(PyObject *self, PyObject *const *args, Py_ssize_t nargs) int chr; PyObject *default_value = NULL; - if (!_PyArg_CheckPositional("name", nargs, 1, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0])) { - goto exit; - } - if (PyUnicode_GET_LENGTH(args[0]) != 1) { - _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]); - goto exit; - } - chr = PyUnicode_READ_CHAR(args[0], 0); - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: + if (!_PyArg_CheckPositional("name", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0])) { + goto exit; + } + if (PyUnicode_GET_LENGTH(args[0]) != 1) { + _PyArg_BadArgument("name", "argument 1", "a unicode character", args[0]); + goto exit; + } + chr = PyUnicode_READ_CHAR(args[0], 0); + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: return_value = unicodedata_UCD_name_impl(self, chr, default_value); exit: @@ -559,4 +559,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=10c23477dbe8a202 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=10c23477dbe8a202 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h b/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h index 77ea04a353..1545c83e26 100644 --- a/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h +++ b/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(zlib_compress__doc__, " Compression level, in 0-9 or -1."); #define ZLIB_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)(void(*)(void))zlib_compress, METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__}, + {"compress", (PyCFunction)(void(*)(void))zlib_compress, METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__}, static PyObject * zlib_compress_impl(PyObject *module, Py_buffer *data, int level); @@ -24,36 +24,36 @@ zlib_compress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "level", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int level = Z_DEFAULT_COMPRESSION; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - level = _PyLong_AsInt(args[1]); - if (level == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + level = _PyLong_AsInt(args[1]); + if (level == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = zlib_compress_impl(module, &data, level); exit: @@ -79,7 +79,7 @@ PyDoc_STRVAR(zlib_decompress__doc__, " The initial output buffer size."); #define ZLIB_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))zlib_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__}, + {"decompress", (PyCFunction)(void(*)(void))zlib_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__}, static PyObject * zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits, @@ -90,45 +90,45 @@ zlib_decompress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "wbits", "bufsize", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int wbits = MAX_WBITS; Py_ssize_t bufsize = DEF_BUF_SIZE; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - wbits = _PyLong_AsInt(args[1]); - if (wbits == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!ssize_t_converter(args[2], &bufsize)) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[1]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!ssize_t_converter(args[2], &bufsize)) { + goto exit; + } +skip_optional_pos: return_value = zlib_decompress_impl(module, &data, wbits, bufsize); exit: @@ -171,7 +171,7 @@ PyDoc_STRVAR(zlib_compressobj__doc__, " containing subsequences that are likely to occur in the input data."); #define ZLIB_COMPRESSOBJ_METHODDEF \ - {"compressobj", (PyCFunction)(void(*)(void))zlib_compressobj, METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__}, + {"compressobj", (PyCFunction)(void(*)(void))zlib_compressobj, METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__}, static PyObject * zlib_compressobj_impl(PyObject *module, int level, int method, int wbits, @@ -182,9 +182,9 @@ zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"level", "method", "wbits", "memLevel", "strategy", "zdict", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "compressobj", 0}; - PyObject *argsbuf[6]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "compressobj", 0}; + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int level = Z_DEFAULT_COMPRESSION; int method = DEFLATED; int wbits = MAX_WBITS; @@ -192,91 +192,91 @@ zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb int strategy = Z_DEFAULT_STRATEGY; Py_buffer zdict = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 6, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - level = _PyLong_AsInt(args[0]); - if (level == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - method = _PyLong_AsInt(args[1]); - if (method == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - wbits = _PyLong_AsInt(args[2]); - if (wbits == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[3]) { - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - memLevel = _PyLong_AsInt(args[3]); - if (memLevel == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[4]) { - if (PyFloat_Check(args[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - strategy = _PyLong_AsInt(args[4]); - if (strategy == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&zdict, 'C')) { - _PyArg_BadArgument("compressobj", "argument 'zdict'", "contiguous buffer", args[5]); - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 6, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + level = _PyLong_AsInt(args[0]); + if (level == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + method = _PyLong_AsInt(args[1]); + if (method == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[2]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + memLevel = _PyLong_AsInt(args[3]); + if (memLevel == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + strategy = _PyLong_AsInt(args[4]); + if (strategy == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&zdict, 'C')) { + _PyArg_BadArgument("compressobj", "argument 'zdict'", "contiguous buffer", args[5]); + goto exit; + } +skip_optional_pos: return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict); exit: @@ -301,7 +301,7 @@ PyDoc_STRVAR(zlib_decompressobj__doc__, " dictionary as used by the compressor that produced the input data."); #define ZLIB_DECOMPRESSOBJ_METHODDEF \ - {"decompressobj", (PyCFunction)(void(*)(void))zlib_decompressobj, METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__}, + {"decompressobj", (PyCFunction)(void(*)(void))zlib_decompressobj, METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__}, static PyObject * zlib_decompressobj_impl(PyObject *module, int wbits, PyObject *zdict); @@ -311,35 +311,35 @@ zlib_decompressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"wbits", "zdict", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decompressobj", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "decompressobj", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int wbits = MAX_WBITS; PyObject *zdict = NULL; - 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]) { - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - wbits = _PyLong_AsInt(args[0]); - if (wbits == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - zdict = args[1]; -skip_optional_pos: + 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]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[0]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + zdict = args[1]; +skip_optional_pos: return_value = zlib_decompressobj_impl(module, wbits, zdict); exit: @@ -371,13 +371,13 @@ zlib_Compress_compress(compobject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", "argument", "contiguous buffer", arg); + goto exit; + } return_value = zlib_Compress_compress_impl(self, &data); exit: @@ -407,7 +407,7 @@ PyDoc_STRVAR(zlib_Decompress_decompress__doc__, "Call the flush() method to clear these buffers."); #define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))zlib_Decompress_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__}, + {"decompress", (PyCFunction)(void(*)(void))zlib_Decompress_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__}, static PyObject * zlib_Decompress_decompress_impl(compobject *self, Py_buffer *data, @@ -418,30 +418,30 @@ zlib_Decompress_decompress(compobject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "max_length", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - if (!ssize_t_converter(args[1], &max_length)) { - goto exit; - } -skip_optional_pos: + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!ssize_t_converter(args[1], &max_length)) { + goto exit; + } +skip_optional_pos: return_value = zlib_Decompress_decompress_impl(self, &data, max_length); exit: @@ -466,7 +466,7 @@ PyDoc_STRVAR(zlib_Compress_flush__doc__, " can still be compressed."); #define ZLIB_COMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)(void(*)(void))zlib_Compress_flush, METH_FASTCALL, zlib_Compress_flush__doc__}, + {"flush", (PyCFunction)(void(*)(void))zlib_Compress_flush, METH_FASTCALL, zlib_Compress_flush__doc__}, static PyObject * zlib_Compress_flush_impl(compobject *self, int mode); @@ -477,22 +477,22 @@ zlib_Compress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; int mode = Z_FINISH; - if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[0]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[0]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = zlib_Compress_flush_impl(self, mode); exit: @@ -523,39 +523,39 @@ zlib_Compress_copy(compobject *self, PyObject *Py_UNUSED(ignored)) #if defined(HAVE_ZLIB_COPY) -PyDoc_STRVAR(zlib_Compress___copy____doc__, -"__copy__($self, /)\n" -"--\n" -"\n"); - -#define ZLIB_COMPRESS___COPY___METHODDEF \ - {"__copy__", (PyCFunction)zlib_Compress___copy__, METH_NOARGS, zlib_Compress___copy____doc__}, - -static PyObject * -zlib_Compress___copy___impl(compobject *self); - -static PyObject * -zlib_Compress___copy__(compobject *self, PyObject *Py_UNUSED(ignored)) -{ - return zlib_Compress___copy___impl(self); -} - -#endif /* defined(HAVE_ZLIB_COPY) */ - -#if defined(HAVE_ZLIB_COPY) - -PyDoc_STRVAR(zlib_Compress___deepcopy____doc__, -"__deepcopy__($self, memo, /)\n" -"--\n" -"\n"); - -#define ZLIB_COMPRESS___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)zlib_Compress___deepcopy__, METH_O, zlib_Compress___deepcopy____doc__}, - -#endif /* defined(HAVE_ZLIB_COPY) */ - -#if defined(HAVE_ZLIB_COPY) - +PyDoc_STRVAR(zlib_Compress___copy____doc__, +"__copy__($self, /)\n" +"--\n" +"\n"); + +#define ZLIB_COMPRESS___COPY___METHODDEF \ + {"__copy__", (PyCFunction)zlib_Compress___copy__, METH_NOARGS, zlib_Compress___copy____doc__}, + +static PyObject * +zlib_Compress___copy___impl(compobject *self); + +static PyObject * +zlib_Compress___copy__(compobject *self, PyObject *Py_UNUSED(ignored)) +{ + return zlib_Compress___copy___impl(self); +} + +#endif /* defined(HAVE_ZLIB_COPY) */ + +#if defined(HAVE_ZLIB_COPY) + +PyDoc_STRVAR(zlib_Compress___deepcopy____doc__, +"__deepcopy__($self, memo, /)\n" +"--\n" +"\n"); + +#define ZLIB_COMPRESS___DEEPCOPY___METHODDEF \ + {"__deepcopy__", (PyCFunction)zlib_Compress___deepcopy__, METH_O, zlib_Compress___deepcopy____doc__}, + +#endif /* defined(HAVE_ZLIB_COPY) */ + +#if defined(HAVE_ZLIB_COPY) + PyDoc_STRVAR(zlib_Decompress_copy__doc__, "copy($self, /)\n" "--\n" @@ -576,39 +576,39 @@ zlib_Decompress_copy(compobject *self, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_ZLIB_COPY) */ -#if defined(HAVE_ZLIB_COPY) - -PyDoc_STRVAR(zlib_Decompress___copy____doc__, -"__copy__($self, /)\n" -"--\n" -"\n"); - -#define ZLIB_DECOMPRESS___COPY___METHODDEF \ - {"__copy__", (PyCFunction)zlib_Decompress___copy__, METH_NOARGS, zlib_Decompress___copy____doc__}, - -static PyObject * -zlib_Decompress___copy___impl(compobject *self); - -static PyObject * -zlib_Decompress___copy__(compobject *self, PyObject *Py_UNUSED(ignored)) -{ - return zlib_Decompress___copy___impl(self); -} - -#endif /* defined(HAVE_ZLIB_COPY) */ - -#if defined(HAVE_ZLIB_COPY) - -PyDoc_STRVAR(zlib_Decompress___deepcopy____doc__, -"__deepcopy__($self, memo, /)\n" -"--\n" -"\n"); - -#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)zlib_Decompress___deepcopy__, METH_O, zlib_Decompress___deepcopy____doc__}, - -#endif /* defined(HAVE_ZLIB_COPY) */ - +#if defined(HAVE_ZLIB_COPY) + +PyDoc_STRVAR(zlib_Decompress___copy____doc__, +"__copy__($self, /)\n" +"--\n" +"\n"); + +#define ZLIB_DECOMPRESS___COPY___METHODDEF \ + {"__copy__", (PyCFunction)zlib_Decompress___copy__, METH_NOARGS, zlib_Decompress___copy____doc__}, + +static PyObject * +zlib_Decompress___copy___impl(compobject *self); + +static PyObject * +zlib_Decompress___copy__(compobject *self, PyObject *Py_UNUSED(ignored)) +{ + return zlib_Decompress___copy___impl(self); +} + +#endif /* defined(HAVE_ZLIB_COPY) */ + +#if defined(HAVE_ZLIB_COPY) + +PyDoc_STRVAR(zlib_Decompress___deepcopy____doc__, +"__deepcopy__($self, memo, /)\n" +"--\n" +"\n"); + +#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF \ + {"__deepcopy__", (PyCFunction)zlib_Decompress___deepcopy__, METH_O, zlib_Decompress___deepcopy____doc__}, + +#endif /* defined(HAVE_ZLIB_COPY) */ + PyDoc_STRVAR(zlib_Decompress_flush__doc__, "flush($self, length=zlib.DEF_BUF_SIZE, /)\n" "--\n" @@ -619,7 +619,7 @@ PyDoc_STRVAR(zlib_Decompress_flush__doc__, " the initial size of the output buffer."); #define ZLIB_DECOMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)(void(*)(void))zlib_Decompress_flush, METH_FASTCALL, zlib_Decompress_flush__doc__}, + {"flush", (PyCFunction)(void(*)(void))zlib_Decompress_flush, METH_FASTCALL, zlib_Decompress_flush__doc__}, static PyObject * zlib_Decompress_flush_impl(compobject *self, Py_ssize_t length); @@ -630,16 +630,16 @@ zlib_Decompress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t length = DEF_BUF_SIZE; - if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { - goto exit; - } - if (nargs < 1) { - goto skip_optional; - } - if (!ssize_t_converter(args[0], &length)) { + if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { goto exit; } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!ssize_t_converter(args[0], &length)) { + goto exit; + } +skip_optional: return_value = zlib_Decompress_flush_impl(self, length); exit: @@ -658,7 +658,7 @@ PyDoc_STRVAR(zlib_adler32__doc__, "The returned checksum is an integer."); #define ZLIB_ADLER32_METHODDEF \ - {"adler32", (PyCFunction)(void(*)(void))zlib_adler32, METH_FASTCALL, zlib_adler32__doc__}, + {"adler32", (PyCFunction)(void(*)(void))zlib_adler32, METH_FASTCALL, zlib_adler32__doc__}, static PyObject * zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value); @@ -670,29 +670,29 @@ zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; unsigned int value = 1; - if (!_PyArg_CheckPositional("adler32", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("adler32", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (value == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("adler32", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("adler32", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (value == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = zlib_adler32_impl(module, &data, value); exit: @@ -716,7 +716,7 @@ PyDoc_STRVAR(zlib_crc32__doc__, "The returned checksum is an integer."); #define ZLIB_CRC32_METHODDEF \ - {"crc32", (PyCFunction)(void(*)(void))zlib_crc32, METH_FASTCALL, zlib_crc32__doc__}, + {"crc32", (PyCFunction)(void(*)(void))zlib_crc32, METH_FASTCALL, zlib_crc32__doc__}, static PyObject * zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value); @@ -728,29 +728,29 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer data = {NULL, NULL}; unsigned int value = 0; - if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&data, 'C')) { - _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); - if (value == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (value == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = zlib_crc32_impl(module, &data, value); exit: @@ -766,23 +766,23 @@ exit: #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -#ifndef ZLIB_COMPRESS___COPY___METHODDEF - #define ZLIB_COMPRESS___COPY___METHODDEF -#endif /* !defined(ZLIB_COMPRESS___COPY___METHODDEF) */ - -#ifndef ZLIB_COMPRESS___DEEPCOPY___METHODDEF - #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF -#endif /* !defined(ZLIB_COMPRESS___DEEPCOPY___METHODDEF) */ - +#ifndef ZLIB_COMPRESS___COPY___METHODDEF + #define ZLIB_COMPRESS___COPY___METHODDEF +#endif /* !defined(ZLIB_COMPRESS___COPY___METHODDEF) */ + +#ifndef ZLIB_COMPRESS___DEEPCOPY___METHODDEF + #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF +#endif /* !defined(ZLIB_COMPRESS___DEEPCOPY___METHODDEF) */ + #ifndef ZLIB_DECOMPRESS_COPY_METHODDEF #define ZLIB_DECOMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */ - -#ifndef ZLIB_DECOMPRESS___COPY___METHODDEF - #define ZLIB_DECOMPRESS___COPY___METHODDEF -#endif /* !defined(ZLIB_DECOMPRESS___COPY___METHODDEF) */ - -#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF - #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF -#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ -/*[clinic end generated code: output=faae38ef96b88b16 input=a9049054013a1b77]*/ + +#ifndef ZLIB_DECOMPRESS___COPY___METHODDEF + #define ZLIB_DECOMPRESS___COPY___METHODDEF +#endif /* !defined(ZLIB_DECOMPRESS___COPY___METHODDEF) */ + +#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF + #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF +#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ +/*[clinic end generated code: output=faae38ef96b88b16 input=a9049054013a1b77]*/ |