diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Objects/clinic | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Objects/clinic')
18 files changed, 2203 insertions, 2203 deletions
diff --git a/contrib/tools/python3/src/Objects/clinic/bytearrayobject.c.h b/contrib/tools/python3/src/Objects/clinic/bytearrayobject.c.h index fcada9abad..35ba1ff3d5 100644 --- a/contrib/tools/python3/src/Objects/clinic/bytearrayobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/bytearrayobject.c.h @@ -38,86 +38,86 @@ bytearray_copy(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) return bytearray_copy_impl(self); } -PyDoc_STRVAR(bytearray_removeprefix__doc__, -"removeprefix($self, prefix, /)\n" -"--\n" -"\n" -"Return a bytearray with the given prefix string removed if present.\n" -"\n" -"If the bytearray starts with the prefix string, return\n" -"bytearray[len(prefix):]. Otherwise, return a copy of the original\n" -"bytearray."); - -#define BYTEARRAY_REMOVEPREFIX_METHODDEF \ - {"removeprefix", (PyCFunction)bytearray_removeprefix, METH_O, bytearray_removeprefix__doc__}, - -static PyObject * -bytearray_removeprefix_impl(PyByteArrayObject *self, Py_buffer *prefix); - -static PyObject * -bytearray_removeprefix(PyByteArrayObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - Py_buffer prefix = {NULL, NULL}; - - if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&prefix, 'C')) { - _PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg); - goto exit; - } - return_value = bytearray_removeprefix_impl(self, &prefix); - -exit: - /* Cleanup for prefix */ - if (prefix.obj) { - PyBuffer_Release(&prefix); - } - - return return_value; -} - -PyDoc_STRVAR(bytearray_removesuffix__doc__, -"removesuffix($self, suffix, /)\n" -"--\n" -"\n" -"Return a bytearray with the given suffix string removed if present.\n" -"\n" -"If the bytearray ends with the suffix string and that suffix is not\n" -"empty, return bytearray[:-len(suffix)]. Otherwise, return a copy of\n" -"the original bytearray."); - -#define BYTEARRAY_REMOVESUFFIX_METHODDEF \ - {"removesuffix", (PyCFunction)bytearray_removesuffix, METH_O, bytearray_removesuffix__doc__}, - -static PyObject * -bytearray_removesuffix_impl(PyByteArrayObject *self, Py_buffer *suffix); - -static PyObject * -bytearray_removesuffix(PyByteArrayObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - Py_buffer suffix = {NULL, NULL}; - - if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&suffix, 'C')) { - _PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg); - goto exit; - } - return_value = bytearray_removesuffix_impl(self, &suffix); - -exit: - /* Cleanup for suffix */ - if (suffix.obj) { - PyBuffer_Release(&suffix); - } - - return return_value; -} - +PyDoc_STRVAR(bytearray_removeprefix__doc__, +"removeprefix($self, prefix, /)\n" +"--\n" +"\n" +"Return a bytearray with the given prefix string removed if present.\n" +"\n" +"If the bytearray starts with the prefix string, return\n" +"bytearray[len(prefix):]. Otherwise, return a copy of the original\n" +"bytearray."); + +#define BYTEARRAY_REMOVEPREFIX_METHODDEF \ + {"removeprefix", (PyCFunction)bytearray_removeprefix, METH_O, bytearray_removeprefix__doc__}, + +static PyObject * +bytearray_removeprefix_impl(PyByteArrayObject *self, Py_buffer *prefix); + +static PyObject * +bytearray_removeprefix(PyByteArrayObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer prefix = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&prefix, 'C')) { + _PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg); + goto exit; + } + return_value = bytearray_removeprefix_impl(self, &prefix); + +exit: + /* Cleanup for prefix */ + if (prefix.obj) { + PyBuffer_Release(&prefix); + } + + return return_value; +} + +PyDoc_STRVAR(bytearray_removesuffix__doc__, +"removesuffix($self, suffix, /)\n" +"--\n" +"\n" +"Return a bytearray with the given suffix string removed if present.\n" +"\n" +"If the bytearray ends with the suffix string and that suffix is not\n" +"empty, return bytearray[:-len(suffix)]. Otherwise, return a copy of\n" +"the original bytearray."); + +#define BYTEARRAY_REMOVESUFFIX_METHODDEF \ + {"removesuffix", (PyCFunction)bytearray_removesuffix, METH_O, bytearray_removesuffix__doc__}, + +static PyObject * +bytearray_removesuffix_impl(PyByteArrayObject *self, Py_buffer *suffix); + +static PyObject * +bytearray_removesuffix(PyByteArrayObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer suffix = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&suffix, 'C')) { + _PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg); + goto exit; + } + return_value = bytearray_removesuffix_impl(self, &suffix); + +exit: + /* Cleanup for suffix */ + if (suffix.obj) { + PyBuffer_Release(&suffix); + } + + return return_value; +} + PyDoc_STRVAR(bytearray_translate__doc__, "translate($self, table, /, delete=b\'\')\n" "--\n" @@ -131,7 +131,7 @@ PyDoc_STRVAR(bytearray_translate__doc__, "The remaining characters are mapped through the given translation table."); #define BYTEARRAY_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)(void(*)(void))bytearray_translate, METH_FASTCALL|METH_KEYWORDS, bytearray_translate__doc__}, + {"translate", (PyCFunction)(void(*)(void))bytearray_translate, METH_FASTCALL|METH_KEYWORDS, bytearray_translate__doc__}, static PyObject * bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, @@ -142,22 +142,22 @@ bytearray_translate(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "delete", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *table; PyObject *deletechars = NULL; - 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; } - table = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - deletechars = args[1]; -skip_optional_pos: + table = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + deletechars = args[1]; +skip_optional_pos: return_value = bytearray_translate_impl(self, table, deletechars); exit: @@ -176,7 +176,7 @@ PyDoc_STRVAR(bytearray_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, + {"maketrans", (PyCFunction)(void(*)(void))bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); @@ -188,23 +188,23 @@ bytearray_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs) Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&frm, 'C')) { + _PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&to, 'C')) { + _PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]); goto exit; } - if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&frm, 'C')) { - _PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&to, 'C')) { - _PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]); - goto exit; - } return_value = bytearray_maketrans_impl(&frm, &to); exit: @@ -234,7 +234,7 @@ PyDoc_STRVAR(bytearray_replace__doc__, "replaced."); #define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, + {"replace", (PyCFunction)(void(*)(void))bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, @@ -248,44 +248,44 @@ bytearray_replace(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nar Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { + if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&old, 'C')) { + _PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&new, 'C')) { + _PyArg_BadArgument("replace", "argument 2", "contiguous buffer", 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; } - if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&old, 'C')) { - _PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&new, 'C')) { - _PyArg_BadArgument("replace", "argument 2", "contiguous buffer", 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; - } - { - 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: + { + 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: return_value = bytearray_replace_impl(self, &old, &new, count); exit: @@ -316,7 +316,7 @@ PyDoc_STRVAR(bytearray_split__doc__, " -1 (the default value) means no limit."); #define BYTEARRAY_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))bytearray_split, METH_FASTCALL|METH_KEYWORDS, bytearray_split__doc__}, + {"split", (PyCFunction)(void(*)(void))bytearray_split, METH_FASTCALL|METH_KEYWORDS, bytearray_split__doc__}, static PyObject * bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, @@ -327,43 +327,43 @@ bytearray_split(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - 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]) { - sep = 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: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = 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 = bytearray_split_impl(self, sep, maxsplit); exit: @@ -420,7 +420,7 @@ PyDoc_STRVAR(bytearray_rsplit__doc__, "Splitting is done starting at the end of the bytearray and working to the front."); #define BYTEARRAY_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))bytearray_rsplit, METH_FASTCALL|METH_KEYWORDS, bytearray_rsplit__doc__}, + {"rsplit", (PyCFunction)(void(*)(void))bytearray_rsplit, METH_FASTCALL|METH_KEYWORDS, bytearray_rsplit__doc__}, static PyObject * bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, @@ -431,43 +431,43 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - 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]) { - sep = 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: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = 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 = bytearray_rsplit_impl(self, sep, maxsplit); exit: @@ -504,7 +504,7 @@ PyDoc_STRVAR(bytearray_insert__doc__, " The item to be inserted."); #define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, + {"insert", (PyCFunction)(void(*)(void))bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); @@ -516,29 +516,29 @@ bytearray_insert(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg Py_ssize_t index; int item; - if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { + 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; + } + index = ival; + } + if (!_getbytevalue(args[1], &item)) { 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; - } - index = ival; - } - if (!_getbytevalue(args[1], &item)) { - goto exit; - } return_value = bytearray_insert_impl(self, index, item); exit: @@ -566,7 +566,7 @@ bytearray_append(PyByteArrayObject *self, PyObject *arg) PyObject *return_value = NULL; int item; - if (!_getbytevalue(arg, &item)) { + if (!_getbytevalue(arg, &item)) { goto exit; } return_value = bytearray_append_impl(self, item); @@ -600,7 +600,7 @@ PyDoc_STRVAR(bytearray_pop__doc__, "If no index argument is given, will pop the last item."); #define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, + {"pop", (PyCFunction)(void(*)(void))bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); @@ -611,30 +611,30 @@ bytearray_pop(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t index = -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; } - 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; - } - index = ival; - } -skip_optional: + { + 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; + } +skip_optional: return_value = bytearray_pop_impl(self, index); exit: @@ -662,7 +662,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg) PyObject *return_value = NULL; int value; - if (!_getbytevalue(arg, &value)) { + if (!_getbytevalue(arg, &value)) { goto exit; } return_value = bytearray_remove_impl(self, value); @@ -680,7 +680,7 @@ PyDoc_STRVAR(bytearray_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTEARRAY_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, + {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, static PyObject * bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -691,14 +691,14 @@ bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytearray_strip_impl(self, bytes); exit: @@ -714,7 +714,7 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTEARRAY_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, + {"lstrip", (PyCFunction)(void(*)(void))bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -725,14 +725,14 @@ bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytearray_lstrip_impl(self, bytes); exit: @@ -748,7 +748,7 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTEARRAY_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, + {"rstrip", (PyCFunction)(void(*)(void))bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -759,14 +759,14 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytearray_rstrip_impl(self, bytes); exit: @@ -789,7 +789,7 @@ PyDoc_STRVAR(bytearray_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTEARRAY_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))bytearray_decode, METH_FASTCALL|METH_KEYWORDS, bytearray_decode__doc__}, + {"decode", (PyCFunction)(void(*)(void))bytearray_decode, METH_FASTCALL|METH_KEYWORDS, bytearray_decode__doc__}, static PyObject * bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, @@ -800,51 +800,51 @@ bytearray_decode(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = NULL; - 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]) { + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); + goto exit; + } + 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; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); - goto exit; - } - 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; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); - goto exit; - } - 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; - } -skip_optional_pos: + 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; + } +skip_optional_pos: return_value = bytearray_decode_impl(self, encoding, errors); exit: @@ -874,7 +874,7 @@ PyDoc_STRVAR(bytearray_splitlines__doc__, "true."); #define BYTEARRAY_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))bytearray_splitlines, METH_FASTCALL|METH_KEYWORDS, bytearray_splitlines__doc__}, + {"splitlines", (PyCFunction)(void(*)(void))bytearray_splitlines, METH_FASTCALL|METH_KEYWORDS, bytearray_splitlines__doc__}, static PyObject * bytearray_splitlines_impl(PyByteArrayObject *self, int keepends); @@ -884,28 +884,28 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - 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; - } - keepends = _PyLong_AsInt(args[0]); - if (keepends == -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; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = bytearray_splitlines_impl(self, keepends); exit: @@ -933,89 +933,89 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; PyObject *string; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("fromhex", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("fromhex", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - string = arg; + string = arg; return_value = bytearray_fromhex_impl(type, string); exit: return return_value; } -PyDoc_STRVAR(bytearray_hex__doc__, -"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" -"--\n" -"\n" -"Create a str of hexadecimal numbers from a bytearray object.\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" -"Example:\n" -">>> value = bytearray([0xb9, 0x01, 0xef])\n" -">>> value.hex()\n" -"\'b901ef\'\n" -">>> value.hex(\':\')\n" -"\'b9:01:ef\'\n" -">>> value.hex(\':\', 2)\n" -"\'b9:01ef\'\n" -">>> value.hex(\':\', -2)\n" -"\'b901:ef\'"); - -#define BYTEARRAY_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))bytearray_hex, METH_FASTCALL|METH_KEYWORDS, bytearray_hex__doc__}, - -static PyObject * -bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep); - -static PyObject * -bytearray_hex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *sep = NULL; - int bytes_per_sep = 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]) { - sep = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bytes_per_sep = _PyLong_AsInt(args[1]); - if (bytes_per_sep == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = bytearray_hex_impl(self, sep, bytes_per_sep); - -exit: - return return_value; -} - +PyDoc_STRVAR(bytearray_hex__doc__, +"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" +"--\n" +"\n" +"Create a str of hexadecimal numbers from a bytearray object.\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" +"Example:\n" +">>> value = bytearray([0xb9, 0x01, 0xef])\n" +">>> value.hex()\n" +"\'b901ef\'\n" +">>> value.hex(\':\')\n" +"\'b9:01:ef\'\n" +">>> value.hex(\':\', 2)\n" +"\'b9:01ef\'\n" +">>> value.hex(\':\', -2)\n" +"\'b901:ef\'"); + +#define BYTEARRAY_HEX_METHODDEF \ + {"hex", (PyCFunction)(void(*)(void))bytearray_hex, METH_FASTCALL|METH_KEYWORDS, bytearray_hex__doc__}, + +static PyObject * +bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep); + +static PyObject * +bytearray_hex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *sep = NULL; + int bytes_per_sep = 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]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bytes_per_sep = _PyLong_AsInt(args[1]); + if (bytes_per_sep == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = bytearray_hex_impl(self, sep, bytes_per_sep); + +exit: + return return_value; +} + PyDoc_STRVAR(bytearray_reduce__doc__, "__reduce__($self, /)\n" "--\n" @@ -1041,7 +1041,7 @@ PyDoc_STRVAR(bytearray_reduce_ex__doc__, "Return state information for pickling."); #define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)(void(*)(void))bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, + {"__reduce_ex__", (PyCFunction)(void(*)(void))bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); @@ -1052,22 +1052,22 @@ bytearray_reduce_ex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n PyObject *return_value = NULL; int proto = 0; - if (!_PyArg_CheckPositional("__reduce_ex__", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("__reduce_ex__", 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; + } + proto = _PyLong_AsInt(args[0]); + if (proto == -1 && PyErr_Occurred()) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - proto = _PyLong_AsInt(args[0]); - if (proto == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: +skip_optional: return_value = bytearray_reduce_ex_impl(self, proto); exit: @@ -1091,4 +1091,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=b2919f76709e48dc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b2919f76709e48dc input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/bytesobject.c.h b/contrib/tools/python3/src/Objects/clinic/bytesobject.c.h index eb176d83db..063a3777b4 100644 --- a/contrib/tools/python3/src/Objects/clinic/bytesobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/bytesobject.c.h @@ -17,7 +17,7 @@ PyDoc_STRVAR(bytes_split__doc__, " -1 (the default value) means no limit."); #define BYTES_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))bytes_split, METH_FASTCALL|METH_KEYWORDS, bytes_split__doc__}, + {"split", (PyCFunction)(void(*)(void))bytes_split, METH_FASTCALL|METH_KEYWORDS, bytes_split__doc__}, static PyObject * bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -27,43 +27,43 @@ bytes_split(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -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]) { - sep = 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: + 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]) { + sep = 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 = bytes_split_impl(self, sep, maxsplit); exit: @@ -95,13 +95,13 @@ bytes_partition(PyBytesObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer sep = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&sep, 'C')) { + _PyArg_BadArgument("partition", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&sep, 'C')) { - _PyArg_BadArgument("partition", "argument", "contiguous buffer", arg); - goto exit; - } return_value = bytes_partition_impl(self, &sep); exit: @@ -138,13 +138,13 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer sep = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&sep, 'C')) { + _PyArg_BadArgument("rpartition", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&sep, 'C')) { - _PyArg_BadArgument("rpartition", "argument", "contiguous buffer", arg); - goto exit; - } return_value = bytes_rpartition_impl(self, &sep); exit: @@ -173,7 +173,7 @@ PyDoc_STRVAR(bytes_rsplit__doc__, "Splitting is done starting at the end of the bytes and working to the front."); #define BYTES_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))bytes_rsplit, METH_FASTCALL|METH_KEYWORDS, bytes_rsplit__doc__}, + {"rsplit", (PyCFunction)(void(*)(void))bytes_rsplit, METH_FASTCALL|METH_KEYWORDS, bytes_rsplit__doc__}, static PyObject * bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -183,43 +183,43 @@ bytes_rsplit(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -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]) { - sep = 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: + 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]) { + sep = 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 = bytes_rsplit_impl(self, sep, maxsplit); exit: @@ -250,7 +250,7 @@ PyDoc_STRVAR(bytes_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))bytes_strip, METH_FASTCALL, bytes_strip__doc__}, + {"strip", (PyCFunction)(void(*)(void))bytes_strip, METH_FASTCALL, bytes_strip__doc__}, static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes); @@ -261,14 +261,14 @@ bytes_strip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytes_strip_impl(self, bytes); exit: @@ -284,7 +284,7 @@ PyDoc_STRVAR(bytes_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, + {"lstrip", (PyCFunction)(void(*)(void))bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); @@ -295,14 +295,14 @@ bytes_lstrip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytes_lstrip_impl(self, bytes); exit: @@ -318,7 +318,7 @@ PyDoc_STRVAR(bytes_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, + {"rstrip", (PyCFunction)(void(*)(void))bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); @@ -329,14 +329,14 @@ bytes_rstrip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - bytes = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + bytes = args[0]; +skip_optional: return_value = bytes_rstrip_impl(self, bytes); exit: @@ -356,7 +356,7 @@ PyDoc_STRVAR(bytes_translate__doc__, "The remaining characters are mapped through the given translation table."); #define BYTES_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)(void(*)(void))bytes_translate, METH_FASTCALL|METH_KEYWORDS, bytes_translate__doc__}, + {"translate", (PyCFunction)(void(*)(void))bytes_translate, METH_FASTCALL|METH_KEYWORDS, bytes_translate__doc__}, static PyObject * bytes_translate_impl(PyBytesObject *self, PyObject *table, @@ -367,22 +367,22 @@ bytes_translate(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "delete", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *table; PyObject *deletechars = NULL; - 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; } - table = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - deletechars = args[1]; -skip_optional_pos: + table = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + deletechars = args[1]; +skip_optional_pos: return_value = bytes_translate_impl(self, table, deletechars); exit: @@ -401,7 +401,7 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", (PyCFunction)(void(*)(void))bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); @@ -413,23 +413,23 @@ bytes_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs) Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&frm, 'C')) { - _PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&to, 'C')) { - _PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]); - goto exit; - } + if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&frm, 'C')) { + _PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&to, 'C')) { + _PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]); + goto exit; + } return_value = bytes_maketrans_impl(&frm, &to); exit: @@ -459,7 +459,7 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))bytes_replace, METH_FASTCALL, bytes_replace__doc__}, + {"replace", (PyCFunction)(void(*)(void))bytes_replace, METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, @@ -473,44 +473,44 @@ bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs) Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&old, 'C')) { - _PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]); - goto exit; - } - if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&new, 'C')) { - _PyArg_BadArgument("replace", "argument 2", "contiguous buffer", 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; - } - { - 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: + if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&old, 'C')) { + _PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&new, 'C')) { + _PyArg_BadArgument("replace", "argument 2", "contiguous buffer", 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; + } + { + 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: return_value = bytes_replace_impl(self, &old, &new, count); exit: @@ -526,85 +526,85 @@ exit: return return_value; } -PyDoc_STRVAR(bytes_removeprefix__doc__, -"removeprefix($self, prefix, /)\n" -"--\n" -"\n" -"Return a bytes object with the given prefix string removed if present.\n" -"\n" -"If the bytes starts with the prefix string, return bytes[len(prefix):].\n" -"Otherwise, return a copy of the original bytes."); - -#define BYTES_REMOVEPREFIX_METHODDEF \ - {"removeprefix", (PyCFunction)bytes_removeprefix, METH_O, bytes_removeprefix__doc__}, - -static PyObject * -bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix); - -static PyObject * -bytes_removeprefix(PyBytesObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - Py_buffer prefix = {NULL, NULL}; - - if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&prefix, 'C')) { - _PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg); - goto exit; - } - return_value = bytes_removeprefix_impl(self, &prefix); - -exit: - /* Cleanup for prefix */ - if (prefix.obj) { - PyBuffer_Release(&prefix); - } - - return return_value; -} - -PyDoc_STRVAR(bytes_removesuffix__doc__, -"removesuffix($self, suffix, /)\n" -"--\n" -"\n" -"Return a bytes object with the given suffix string removed if present.\n" -"\n" -"If the bytes ends with the suffix string and that suffix is not empty,\n" -"return bytes[:-len(prefix)]. Otherwise, return a copy of the original\n" -"bytes."); - -#define BYTES_REMOVESUFFIX_METHODDEF \ - {"removesuffix", (PyCFunction)bytes_removesuffix, METH_O, bytes_removesuffix__doc__}, - -static PyObject * -bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix); - -static PyObject * -bytes_removesuffix(PyBytesObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - Py_buffer suffix = {NULL, NULL}; - - if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (!PyBuffer_IsContiguous(&suffix, 'C')) { - _PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg); - goto exit; - } - return_value = bytes_removesuffix_impl(self, &suffix); - -exit: - /* Cleanup for suffix */ - if (suffix.obj) { - PyBuffer_Release(&suffix); - } - - return return_value; -} - +PyDoc_STRVAR(bytes_removeprefix__doc__, +"removeprefix($self, prefix, /)\n" +"--\n" +"\n" +"Return a bytes object with the given prefix string removed if present.\n" +"\n" +"If the bytes starts with the prefix string, return bytes[len(prefix):].\n" +"Otherwise, return a copy of the original bytes."); + +#define BYTES_REMOVEPREFIX_METHODDEF \ + {"removeprefix", (PyCFunction)bytes_removeprefix, METH_O, bytes_removeprefix__doc__}, + +static PyObject * +bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix); + +static PyObject * +bytes_removeprefix(PyBytesObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer prefix = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&prefix, 'C')) { + _PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg); + goto exit; + } + return_value = bytes_removeprefix_impl(self, &prefix); + +exit: + /* Cleanup for prefix */ + if (prefix.obj) { + PyBuffer_Release(&prefix); + } + + return return_value; +} + +PyDoc_STRVAR(bytes_removesuffix__doc__, +"removesuffix($self, suffix, /)\n" +"--\n" +"\n" +"Return a bytes object with the given suffix string removed if present.\n" +"\n" +"If the bytes ends with the suffix string and that suffix is not empty,\n" +"return bytes[:-len(prefix)]. Otherwise, return a copy of the original\n" +"bytes."); + +#define BYTES_REMOVESUFFIX_METHODDEF \ + {"removesuffix", (PyCFunction)bytes_removesuffix, METH_O, bytes_removesuffix__doc__}, + +static PyObject * +bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix); + +static PyObject * +bytes_removesuffix(PyBytesObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer suffix = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&suffix, 'C')) { + _PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg); + goto exit; + } + return_value = bytes_removesuffix_impl(self, &suffix); + +exit: + /* Cleanup for suffix */ + if (suffix.obj) { + PyBuffer_Release(&suffix); + } + + return return_value; +} + PyDoc_STRVAR(bytes_decode__doc__, "decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" "--\n" @@ -621,7 +621,7 @@ PyDoc_STRVAR(bytes_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTES_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))bytes_decode, METH_FASTCALL|METH_KEYWORDS, bytes_decode__doc__}, + {"decode", (PyCFunction)(void(*)(void))bytes_decode, METH_FASTCALL|METH_KEYWORDS, bytes_decode__doc__}, static PyObject * bytes_decode_impl(PyBytesObject *self, const char *encoding, @@ -632,51 +632,51 @@ bytes_decode(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = 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 (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); - goto exit; - } - 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; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); - goto exit; - } - 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; - } -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 (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); + goto exit; + } + 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; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); + goto exit; + } + 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; + } +skip_optional_pos: return_value = bytes_decode_impl(self, encoding, errors); exit: @@ -693,7 +693,7 @@ PyDoc_STRVAR(bytes_splitlines__doc__, "true."); #define BYTES_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))bytes_splitlines, METH_FASTCALL|METH_KEYWORDS, bytes_splitlines__doc__}, + {"splitlines", (PyCFunction)(void(*)(void))bytes_splitlines, METH_FASTCALL|METH_KEYWORDS, bytes_splitlines__doc__}, static PyObject * bytes_splitlines_impl(PyBytesObject *self, int keepends); @@ -703,28 +703,28 @@ bytes_splitlines(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - 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; - } - keepends = _PyLong_AsInt(args[0]); - if (keepends == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + 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; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = bytes_splitlines_impl(self, keepends); exit: @@ -752,86 +752,86 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; PyObject *string; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("fromhex", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("fromhex", "argument", "str", arg); goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - string = arg; + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + string = arg; return_value = bytes_fromhex_impl(type, string); exit: return return_value; } - -PyDoc_STRVAR(bytes_hex__doc__, -"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" -"--\n" -"\n" -"Create a str of hexadecimal numbers from a bytes object.\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" -"Example:\n" -">>> value = b\'\\xb9\\x01\\xef\'\n" -">>> value.hex()\n" -"\'b901ef\'\n" -">>> value.hex(\':\')\n" -"\'b9:01:ef\'\n" -">>> value.hex(\':\', 2)\n" -"\'b9:01ef\'\n" -">>> value.hex(\':\', -2)\n" -"\'b901:ef\'"); - -#define BYTES_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))bytes_hex, METH_FASTCALL|METH_KEYWORDS, bytes_hex__doc__}, - -static PyObject * -bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep); - -static PyObject * -bytes_hex(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *sep = NULL; - int bytes_per_sep = 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]) { - sep = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bytes_per_sep = _PyLong_AsInt(args[1]); - if (bytes_per_sep == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = bytes_hex_impl(self, sep, bytes_per_sep); - -exit: - return return_value; -} -/*[clinic end generated code: output=220388917d7bf751 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(bytes_hex__doc__, +"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" +"--\n" +"\n" +"Create a str of hexadecimal numbers from a bytes object.\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" +"Example:\n" +">>> value = b\'\\xb9\\x01\\xef\'\n" +">>> value.hex()\n" +"\'b901ef\'\n" +">>> value.hex(\':\')\n" +"\'b9:01:ef\'\n" +">>> value.hex(\':\', 2)\n" +"\'b9:01ef\'\n" +">>> value.hex(\':\', -2)\n" +"\'b901:ef\'"); + +#define BYTES_HEX_METHODDEF \ + {"hex", (PyCFunction)(void(*)(void))bytes_hex, METH_FASTCALL|METH_KEYWORDS, bytes_hex__doc__}, + +static PyObject * +bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep); + +static PyObject * +bytes_hex(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *sep = NULL; + int bytes_per_sep = 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]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bytes_per_sep = _PyLong_AsInt(args[1]); + if (bytes_per_sep == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = bytes_hex_impl(self, sep, bytes_per_sep); + +exit: + return return_value; +} +/*[clinic end generated code: output=220388917d7bf751 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/codeobject.c.h b/contrib/tools/python3/src/Objects/clinic/codeobject.c.h index 9cddc72838..1dd82278cf 100644 --- a/contrib/tools/python3/src/Objects/clinic/codeobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/codeobject.c.h @@ -1,256 +1,256 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(code_replace__doc__, -"replace($self, /, *, co_argcount=-1, co_posonlyargcount=-1,\n" -" co_kwonlyargcount=-1, co_nlocals=-1, co_stacksize=-1,\n" -" co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None,\n" -" co_names=None, co_varnames=None, co_freevars=None,\n" -" co_cellvars=None, co_filename=None, co_name=None,\n" -" co_lnotab=None)\n" -"--\n" -"\n" -"Return a copy of the code object with new values for the specified fields."); - -#define CODE_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))code_replace, METH_FASTCALL|METH_KEYWORDS, code_replace__doc__}, - -static PyObject * -code_replace_impl(PyCodeObject *self, int co_argcount, - int co_posonlyargcount, int co_kwonlyargcount, - int co_nlocals, int co_stacksize, int co_flags, - int co_firstlineno, PyBytesObject *co_code, - PyObject *co_consts, PyObject *co_names, - PyObject *co_varnames, PyObject *co_freevars, - PyObject *co_cellvars, PyObject *co_filename, - PyObject *co_name, PyBytesObject *co_lnotab); - -static PyObject * -code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_firstlineno", "co_code", "co_consts", "co_names", "co_varnames", "co_freevars", "co_cellvars", "co_filename", "co_name", "co_lnotab", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; - PyObject *argsbuf[16]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - int co_argcount = self->co_argcount; - int co_posonlyargcount = self->co_posonlyargcount; - int co_kwonlyargcount = self->co_kwonlyargcount; - int co_nlocals = self->co_nlocals; - int co_stacksize = self->co_stacksize; - int co_flags = self->co_flags; - int co_firstlineno = self->co_firstlineno; - PyBytesObject *co_code = (PyBytesObject *)self->co_code; - PyObject *co_consts = self->co_consts; - PyObject *co_names = self->co_names; - PyObject *co_varnames = self->co_varnames; - PyObject *co_freevars = self->co_freevars; - PyObject *co_cellvars = self->co_cellvars; - PyObject *co_filename = self->co_filename; - PyObject *co_name = self->co_name; - PyBytesObject *co_lnotab = (PyBytesObject *)self->co_lnotab; - - 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]) { - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - co_argcount = _PyLong_AsInt(args[0]); - if (co_argcount == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[1]) { - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - co_posonlyargcount = _PyLong_AsInt(args[1]); - if (co_posonlyargcount == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - co_kwonlyargcount = _PyLong_AsInt(args[2]); - if (co_kwonlyargcount == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - if (PyFloat_Check(args[3])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - co_nlocals = _PyLong_AsInt(args[3]); - if (co_nlocals == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[4]) { - if (PyFloat_Check(args[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - co_stacksize = _PyLong_AsInt(args[4]); - if (co_stacksize == -1 && PyErr_Occurred()) { - goto exit; - } - 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; - } - co_flags = _PyLong_AsInt(args[5]); - if (co_flags == -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; - } - co_firstlineno = _PyLong_AsInt(args[6]); - if (co_firstlineno == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[7]) { - if (!PyBytes_Check(args[7])) { - _PyArg_BadArgument("replace", "argument 'co_code'", "bytes", args[7]); - goto exit; - } - co_code = (PyBytesObject *)args[7]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[8]) { - if (!PyTuple_Check(args[8])) { - _PyArg_BadArgument("replace", "argument 'co_consts'", "tuple", args[8]); - goto exit; - } - co_consts = args[8]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[9]) { - if (!PyTuple_Check(args[9])) { - _PyArg_BadArgument("replace", "argument 'co_names'", "tuple", args[9]); - goto exit; - } - co_names = args[9]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[10]) { - if (!PyTuple_Check(args[10])) { - _PyArg_BadArgument("replace", "argument 'co_varnames'", "tuple", args[10]); - goto exit; - } - co_varnames = args[10]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[11]) { - if (!PyTuple_Check(args[11])) { - _PyArg_BadArgument("replace", "argument 'co_freevars'", "tuple", args[11]); - goto exit; - } - co_freevars = args[11]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[12]) { - if (!PyTuple_Check(args[12])) { - _PyArg_BadArgument("replace", "argument 'co_cellvars'", "tuple", args[12]); - goto exit; - } - co_cellvars = args[12]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[13]) { - if (!PyUnicode_Check(args[13])) { - _PyArg_BadArgument("replace", "argument 'co_filename'", "str", args[13]); - goto exit; - } - if (PyUnicode_READY(args[13]) == -1) { - goto exit; - } - co_filename = args[13]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[14]) { - if (!PyUnicode_Check(args[14])) { - _PyArg_BadArgument("replace", "argument 'co_name'", "str", args[14]); - goto exit; - } - if (PyUnicode_READY(args[14]) == -1) { - goto exit; - } - co_name = args[14]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (!PyBytes_Check(args[15])) { - _PyArg_BadArgument("replace", "argument 'co_lnotab'", "bytes", args[15]); - goto exit; - } - co_lnotab = (PyBytesObject *)args[15]; -skip_optional_kwonly: - return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_lnotab); - -exit: - return return_value; -} -/*[clinic end generated code: output=27fe34e82106b220 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(code_replace__doc__, +"replace($self, /, *, co_argcount=-1, co_posonlyargcount=-1,\n" +" co_kwonlyargcount=-1, co_nlocals=-1, co_stacksize=-1,\n" +" co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None,\n" +" co_names=None, co_varnames=None, co_freevars=None,\n" +" co_cellvars=None, co_filename=None, co_name=None,\n" +" co_lnotab=None)\n" +"--\n" +"\n" +"Return a copy of the code object with new values for the specified fields."); + +#define CODE_REPLACE_METHODDEF \ + {"replace", (PyCFunction)(void(*)(void))code_replace, METH_FASTCALL|METH_KEYWORDS, code_replace__doc__}, + +static PyObject * +code_replace_impl(PyCodeObject *self, int co_argcount, + int co_posonlyargcount, int co_kwonlyargcount, + int co_nlocals, int co_stacksize, int co_flags, + int co_firstlineno, PyBytesObject *co_code, + PyObject *co_consts, PyObject *co_names, + PyObject *co_varnames, PyObject *co_freevars, + PyObject *co_cellvars, PyObject *co_filename, + PyObject *co_name, PyBytesObject *co_lnotab); + +static PyObject * +code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_firstlineno", "co_code", "co_consts", "co_names", "co_varnames", "co_freevars", "co_cellvars", "co_filename", "co_name", "co_lnotab", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; + PyObject *argsbuf[16]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + int co_argcount = self->co_argcount; + int co_posonlyargcount = self->co_posonlyargcount; + int co_kwonlyargcount = self->co_kwonlyargcount; + int co_nlocals = self->co_nlocals; + int co_stacksize = self->co_stacksize; + int co_flags = self->co_flags; + int co_firstlineno = self->co_firstlineno; + PyBytesObject *co_code = (PyBytesObject *)self->co_code; + PyObject *co_consts = self->co_consts; + PyObject *co_names = self->co_names; + PyObject *co_varnames = self->co_varnames; + PyObject *co_freevars = self->co_freevars; + PyObject *co_cellvars = self->co_cellvars; + PyObject *co_filename = self->co_filename; + PyObject *co_name = self->co_name; + PyBytesObject *co_lnotab = (PyBytesObject *)self->co_lnotab; + + 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]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + co_argcount = _PyLong_AsInt(args[0]); + if (co_argcount == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + co_posonlyargcount = _PyLong_AsInt(args[1]); + if (co_posonlyargcount == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + co_kwonlyargcount = _PyLong_AsInt(args[2]); + if (co_kwonlyargcount == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + co_nlocals = _PyLong_AsInt(args[3]); + if (co_nlocals == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + co_stacksize = _PyLong_AsInt(args[4]); + if (co_stacksize == -1 && PyErr_Occurred()) { + goto exit; + } + 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; + } + co_flags = _PyLong_AsInt(args[5]); + if (co_flags == -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; + } + co_firstlineno = _PyLong_AsInt(args[6]); + if (co_firstlineno == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[7]) { + if (!PyBytes_Check(args[7])) { + _PyArg_BadArgument("replace", "argument 'co_code'", "bytes", args[7]); + goto exit; + } + co_code = (PyBytesObject *)args[7]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[8]) { + if (!PyTuple_Check(args[8])) { + _PyArg_BadArgument("replace", "argument 'co_consts'", "tuple", args[8]); + goto exit; + } + co_consts = args[8]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[9]) { + if (!PyTuple_Check(args[9])) { + _PyArg_BadArgument("replace", "argument 'co_names'", "tuple", args[9]); + goto exit; + } + co_names = args[9]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[10]) { + if (!PyTuple_Check(args[10])) { + _PyArg_BadArgument("replace", "argument 'co_varnames'", "tuple", args[10]); + goto exit; + } + co_varnames = args[10]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[11]) { + if (!PyTuple_Check(args[11])) { + _PyArg_BadArgument("replace", "argument 'co_freevars'", "tuple", args[11]); + goto exit; + } + co_freevars = args[11]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[12]) { + if (!PyTuple_Check(args[12])) { + _PyArg_BadArgument("replace", "argument 'co_cellvars'", "tuple", args[12]); + goto exit; + } + co_cellvars = args[12]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[13]) { + if (!PyUnicode_Check(args[13])) { + _PyArg_BadArgument("replace", "argument 'co_filename'", "str", args[13]); + goto exit; + } + if (PyUnicode_READY(args[13]) == -1) { + goto exit; + } + co_filename = args[13]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[14]) { + if (!PyUnicode_Check(args[14])) { + _PyArg_BadArgument("replace", "argument 'co_name'", "str", args[14]); + goto exit; + } + if (PyUnicode_READY(args[14]) == -1) { + goto exit; + } + co_name = args[14]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!PyBytes_Check(args[15])) { + _PyArg_BadArgument("replace", "argument 'co_lnotab'", "bytes", args[15]); + goto exit; + } + co_lnotab = (PyBytesObject *)args[15]; +skip_optional_kwonly: + return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_lnotab); + +exit: + return return_value; +} +/*[clinic end generated code: output=27fe34e82106b220 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/complexobject.c.h b/contrib/tools/python3/src/Objects/clinic/complexobject.c.h index 74f4d26d3a..8caa910d03 100644 --- a/contrib/tools/python3/src/Objects/clinic/complexobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/complexobject.c.h @@ -18,32 +18,32 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"real", "imag", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "complex", 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 _PyArg_Parser _parser = {NULL, _keywords, "complex", 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 *r = _PyLong_Zero; PyObject *i = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); - if (!fastargs) { + 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]) { - r = fastargs[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - i = fastargs[1]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + r = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + i = fastargs[1]; +skip_optional_pos: return_value = complex_new_impl(type, r, i); exit: return return_value; } -/*[clinic end generated code: output=a0fe23fdbdc9b06b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a0fe23fdbdc9b06b input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/descrobject.c.h b/contrib/tools/python3/src/Objects/clinic/descrobject.c.h index 13a9e12fb1..d248b91bf4 100644 --- a/contrib/tools/python3/src/Objects/clinic/descrobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/descrobject.c.h @@ -10,17 +10,17 @@ mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"mapping", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "mappingproxy", 0}; - PyObject *argsbuf[1]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); + static _PyArg_Parser _parser = {NULL, _keywords, "mappingproxy", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *mapping; - 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; } - mapping = fastargs[0]; + mapping = fastargs[0]; return_value = mappingproxy_new_impl(type, mapping); exit: @@ -73,46 +73,46 @@ property_init(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"fget", "fset", "fdel", "doc", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "property", 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) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "property", 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) - 0; PyObject *fget = NULL; PyObject *fset = NULL; PyObject *fdel = NULL; PyObject *doc = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 4, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 4, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[0]) { - fget = fastargs[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[1]) { - fset = fastargs[1]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[2]) { - fdel = fastargs[2]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - doc = fastargs[3]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + fget = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[1]) { + fset = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + fdel = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + doc = fastargs[3]; +skip_optional_pos: return_value = property_init_impl((propertyobject *)self, fget, fset, fdel, doc); exit: return return_value; } -/*[clinic end generated code: output=916624e717862abc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=916624e717862abc input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/dictobject.c.h b/contrib/tools/python3/src/Objects/clinic/dictobject.c.h index 51af72a2b8..7395e3bceb 100644 --- a/contrib/tools/python3/src/Objects/clinic/dictobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/dictobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(dict_fromkeys__doc__, "Create a new dictionary with keys from iterable and values set to value."); #define DICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)(void(*)(void))dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, + {"fromkeys", (PyCFunction)(void(*)(void))dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, static PyObject * dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); @@ -21,15 +21,15 @@ dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs) PyObject *iterable; PyObject *value = Py_None; - if (!_PyArg_CheckPositional("fromkeys", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("fromkeys", nargs, 1, 2)) { goto exit; } - iterable = args[0]; - if (nargs < 2) { - goto skip_optional; - } - value = args[1]; -skip_optional: + iterable = args[0]; + if (nargs < 2) { + goto skip_optional; + } + value = args[1]; +skip_optional: return_value = dict_fromkeys_impl(type, iterable, value); exit: @@ -52,7 +52,7 @@ PyDoc_STRVAR(dict_get__doc__, "Return the value for key if key is in the dictionary, else default."); #define DICT_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))dict_get, METH_FASTCALL, dict_get__doc__}, + {"get", (PyCFunction)(void(*)(void))dict_get, METH_FASTCALL, dict_get__doc__}, static PyObject * dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value); @@ -64,15 +64,15 @@ dict_get(PyDictObject *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 = dict_get_impl(self, key, default_value); exit: @@ -88,7 +88,7 @@ PyDoc_STRVAR(dict_setdefault__doc__, "Return the value for key if key is in the dictionary, else default."); #define DICT_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))dict_setdefault, METH_FASTCALL, dict_setdefault__doc__}, + {"setdefault", (PyCFunction)(void(*)(void))dict_setdefault, METH_FASTCALL, dict_setdefault__doc__}, static PyObject * dict_setdefault_impl(PyDictObject *self, PyObject *key, @@ -101,93 +101,93 @@ dict_setdefault(PyDictObject *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 = dict_setdefault_impl(self, key, default_value); exit: return return_value; } - -PyDoc_STRVAR(dict_pop__doc__, -"pop($self, key, default=<unrepresentable>, /)\n" -"--\n" -"\n" -"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n" -"\n" -"If key is not found, default is returned if given, otherwise KeyError is raised"); - -#define DICT_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__}, - -static PyObject * -dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value); - -static PyObject * -dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *key; - PyObject *default_value = NULL; - - if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) { - goto exit; - } - key = args[0]; - if (nargs < 2) { - goto skip_optional; - } - default_value = args[1]; -skip_optional: - return_value = dict_pop_impl(self, key, default_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(dict_popitem__doc__, -"popitem($self, /)\n" -"--\n" -"\n" -"Remove and return a (key, value) pair as a 2-tuple.\n" -"\n" -"Pairs are returned in LIFO (last-in, first-out) order.\n" -"Raises KeyError if the dict is empty."); - -#define DICT_POPITEM_METHODDEF \ - {"popitem", (PyCFunction)dict_popitem, METH_NOARGS, dict_popitem__doc__}, - -static PyObject * -dict_popitem_impl(PyDictObject *self); - -static PyObject * -dict_popitem(PyDictObject *self, PyObject *Py_UNUSED(ignored)) -{ - return dict_popitem_impl(self); -} - -PyDoc_STRVAR(dict___reversed____doc__, -"__reversed__($self, /)\n" -"--\n" -"\n" -"Return a reverse iterator over the dict keys."); - -#define DICT___REVERSED___METHODDEF \ - {"__reversed__", (PyCFunction)dict___reversed__, METH_NOARGS, dict___reversed____doc__}, - -static PyObject * -dict___reversed___impl(PyDictObject *self); - -static PyObject * -dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored)) -{ - return dict___reversed___impl(self); -} -/*[clinic end generated code: output=4d98145508da8fa3 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(dict_pop__doc__, +"pop($self, key, default=<unrepresentable>, /)\n" +"--\n" +"\n" +"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n" +"\n" +"If key is not found, default is returned if given, otherwise KeyError is raised"); + +#define DICT_POP_METHODDEF \ + {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__}, + +static PyObject * +dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value); + +static PyObject * +dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *key; + PyObject *default_value = NULL; + + if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) { + goto exit; + } + key = args[0]; + if (nargs < 2) { + goto skip_optional; + } + default_value = args[1]; +skip_optional: + return_value = dict_pop_impl(self, key, default_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(dict_popitem__doc__, +"popitem($self, /)\n" +"--\n" +"\n" +"Remove and return a (key, value) pair as a 2-tuple.\n" +"\n" +"Pairs are returned in LIFO (last-in, first-out) order.\n" +"Raises KeyError if the dict is empty."); + +#define DICT_POPITEM_METHODDEF \ + {"popitem", (PyCFunction)dict_popitem, METH_NOARGS, dict_popitem__doc__}, + +static PyObject * +dict_popitem_impl(PyDictObject *self); + +static PyObject * +dict_popitem(PyDictObject *self, PyObject *Py_UNUSED(ignored)) +{ + return dict_popitem_impl(self); +} + +PyDoc_STRVAR(dict___reversed____doc__, +"__reversed__($self, /)\n" +"--\n" +"\n" +"Return a reverse iterator over the dict keys."); + +#define DICT___REVERSED___METHODDEF \ + {"__reversed__", (PyCFunction)dict___reversed__, METH_NOARGS, dict___reversed____doc__}, + +static PyObject * +dict___reversed___impl(PyDictObject *self); + +static PyObject * +dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored)) +{ + return dict___reversed___impl(self); +} +/*[clinic end generated code: output=4d98145508da8fa3 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/enumobject.c.h b/contrib/tools/python3/src/Objects/clinic/enumobject.c.h index a22fd43b04..09d4c87e15 100644 --- a/contrib/tools/python3/src/Objects/clinic/enumobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/enumobject.c.h @@ -25,24 +25,24 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "start", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "enumerate", 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; + static _PyArg_Parser _parser = {NULL, _keywords, "enumerate", 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 *start = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { + 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; - } - start = fastargs[1]; -skip_optional_pos: + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + start = fastargs[1]; +skip_optional_pos: return_value = enum_new_impl(type, iterable, start); exit: @@ -68,13 +68,13 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("reversed", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("reversed", PyTuple_GET_SIZE(args), 1, 1)) { + if (!_PyArg_CheckPositional("reversed", PyTuple_GET_SIZE(args), 1, 1)) { goto exit; } - seq = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 0); return_value = reversed_new_impl(type, seq); exit: return return_value; } -/*[clinic end generated code: output=e18c3fefcf914ec7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e18c3fefcf914ec7 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/floatobject.c.h b/contrib/tools/python3/src/Objects/clinic/floatobject.c.h index ae823cd0e4..b7554832b5 100644 --- a/contrib/tools/python3/src/Objects/clinic/floatobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/floatobject.c.h @@ -38,42 +38,42 @@ float___trunc__(PyObject *self, PyObject *Py_UNUSED(ignored)) return float___trunc___impl(self); } -PyDoc_STRVAR(float___floor____doc__, -"__floor__($self, /)\n" -"--\n" -"\n" -"Return the floor as an Integral."); - -#define FLOAT___FLOOR___METHODDEF \ - {"__floor__", (PyCFunction)float___floor__, METH_NOARGS, float___floor____doc__}, - -static PyObject * -float___floor___impl(PyObject *self); - -static PyObject * -float___floor__(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - return float___floor___impl(self); -} - -PyDoc_STRVAR(float___ceil____doc__, -"__ceil__($self, /)\n" -"--\n" -"\n" -"Return the ceiling as an Integral."); - -#define FLOAT___CEIL___METHODDEF \ - {"__ceil__", (PyCFunction)float___ceil__, METH_NOARGS, float___ceil____doc__}, - -static PyObject * -float___ceil___impl(PyObject *self); - -static PyObject * -float___ceil__(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - return float___ceil___impl(self); -} - +PyDoc_STRVAR(float___floor____doc__, +"__floor__($self, /)\n" +"--\n" +"\n" +"Return the floor as an Integral."); + +#define FLOAT___FLOOR___METHODDEF \ + {"__floor__", (PyCFunction)float___floor__, METH_NOARGS, float___floor____doc__}, + +static PyObject * +float___floor___impl(PyObject *self); + +static PyObject * +float___floor__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return float___floor___impl(self); +} + +PyDoc_STRVAR(float___ceil____doc__, +"__ceil__($self, /)\n" +"--\n" +"\n" +"Return the ceiling as an Integral."); + +#define FLOAT___CEIL___METHODDEF \ + {"__ceil__", (PyCFunction)float___ceil__, METH_NOARGS, float___ceil____doc__}, + +static PyObject * +float___ceil___impl(PyObject *self); + +static PyObject * +float___ceil__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return float___ceil___impl(self); +} + PyDoc_STRVAR(float___round____doc__, "__round__($self, ndigits=None, /)\n" "--\n" @@ -83,7 +83,7 @@ PyDoc_STRVAR(float___round____doc__, "When an argument is passed, work like built-in round(x, ndigits)."); #define FLOAT___ROUND___METHODDEF \ - {"__round__", (PyCFunction)(void(*)(void))float___round__, METH_FASTCALL, float___round____doc__}, + {"__round__", (PyCFunction)(void(*)(void))float___round__, METH_FASTCALL, float___round____doc__}, static PyObject * float___round___impl(PyObject *self, PyObject *o_ndigits); @@ -92,16 +92,16 @@ static PyObject * float___round__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *o_ndigits = Py_None; + PyObject *o_ndigits = Py_None; - if (!_PyArg_CheckPositional("__round__", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("__round__", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - o_ndigits = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + o_ndigits = args[0]; +skip_optional: return_value = float___round___impl(self, o_ndigits); exit: @@ -212,14 +212,14 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("float", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("float", PyTuple_GET_SIZE(args), 0, 1)) { + if (!_PyArg_CheckPositional("float", PyTuple_GET_SIZE(args), 0, 1)) { goto exit; } - if (PyTuple_GET_SIZE(args) < 1) { - goto skip_optional; - } - x = PyTuple_GET_ITEM(args, 0); -skip_optional: + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + x = PyTuple_GET_ITEM(args, 0); +skip_optional: return_value = float_new_impl(type, x); exit: @@ -270,19 +270,19 @@ float___getformat__(PyTypeObject *type, PyObject *arg) PyObject *return_value = NULL; const char *typestr; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("__getformat__", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__getformat__", "argument", "str", arg); + goto exit; + } + Py_ssize_t typestr_length; + typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length); + if (typestr == NULL) { + goto exit; + } + if (strlen(typestr) != (size_t)typestr_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } - Py_ssize_t typestr_length; - typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length); - if (typestr == NULL) { - goto exit; - } - if (strlen(typestr) != (size_t)typestr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = float___getformat___impl(type, typestr); exit: @@ -308,7 +308,7 @@ PyDoc_STRVAR(float___set_format____doc__, "This affects how floats are converted to and from binary strings."); #define FLOAT___SET_FORMAT___METHODDEF \ - {"__set_format__", (PyCFunction)(void(*)(void))float___set_format__, METH_FASTCALL|METH_CLASS, float___set_format____doc__}, + {"__set_format__", (PyCFunction)(void(*)(void))float___set_format__, METH_FASTCALL|METH_CLASS, float___set_format____doc__}, static PyObject * float___set_format___impl(PyTypeObject *type, const char *typestr, @@ -321,35 +321,35 @@ float___set_format__(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs const char *typestr; const char *fmt; - if (!_PyArg_CheckPositional("__set_format__", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("__set_format__", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("__set_format__", "argument 1", "str", args[0]); + goto exit; + } + Py_ssize_t typestr_length; + typestr = PyUnicode_AsUTF8AndSize(args[0], &typestr_length); + if (typestr == NULL) { + goto exit; + } + if (strlen(typestr) != (size_t)typestr_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("__set_format__", "argument 2", "str", args[1]); + goto exit; + } + Py_ssize_t fmt_length; + fmt = PyUnicode_AsUTF8AndSize(args[1], &fmt_length); + if (fmt == NULL) { + goto exit; + } + if (strlen(fmt) != (size_t)fmt_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("__set_format__", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t typestr_length; - typestr = PyUnicode_AsUTF8AndSize(args[0], &typestr_length); - if (typestr == NULL) { - goto exit; - } - if (strlen(typestr) != (size_t)typestr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("__set_format__", "argument 2", "str", args[1]); - goto exit; - } - Py_ssize_t fmt_length; - fmt = PyUnicode_AsUTF8AndSize(args[1], &fmt_length); - if (fmt == NULL) { - goto exit; - } - if (strlen(fmt) != (size_t)fmt_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = float___set_format___impl(type, typestr, fmt); exit: @@ -374,17 +374,17 @@ float___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("__format__", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - format_spec = arg; + format_spec = arg; return_value = float___format___impl(self, format_spec); exit: return return_value; } -/*[clinic end generated code: output=25fbbe253f44e2df input=a9049054013a1b77]*/ +/*[clinic end generated code: output=25fbbe253f44e2df input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/funcobject.c.h b/contrib/tools/python3/src/Objects/clinic/funcobject.c.h index 736e2d5d49..17fb13fe08 100644 --- a/contrib/tools/python3/src/Objects/clinic/funcobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/funcobject.c.h @@ -28,51 +28,51 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"code", "globals", "name", "argdefs", "closure", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "function", 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) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "function", 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) - 2; PyCodeObject *code; PyObject *globals; PyObject *name = Py_None; PyObject *defaults = Py_None; PyObject *closure = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 5, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 5, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!PyObject_TypeCheck(fastargs[0], &PyCode_Type)) { - _PyArg_BadArgument("function", "argument 'code'", (&PyCode_Type)->tp_name, fastargs[0]); - goto exit; - } - code = (PyCodeObject *)fastargs[0]; - if (!PyDict_Check(fastargs[1])) { - _PyArg_BadArgument("function", "argument 'globals'", "dict", fastargs[1]); - goto exit; - } - globals = fastargs[1]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[2]) { - name = fastargs[2]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[3]) { - defaults = fastargs[3]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - closure = fastargs[4]; -skip_optional_pos: + if (!PyObject_TypeCheck(fastargs[0], &PyCode_Type)) { + _PyArg_BadArgument("function", "argument 'code'", (&PyCode_Type)->tp_name, fastargs[0]); + goto exit; + } + code = (PyCodeObject *)fastargs[0]; + if (!PyDict_Check(fastargs[1])) { + _PyArg_BadArgument("function", "argument 'globals'", "dict", fastargs[1]); + goto exit; + } + globals = fastargs[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[2]) { + name = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[3]) { + defaults = fastargs[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + closure = fastargs[4]; +skip_optional_pos: return_value = func_new_impl(type, code, globals, name, defaults, closure); exit: return return_value; } -/*[clinic end generated code: output=3d96afa3396e5c82 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3d96afa3396e5c82 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/listobject.c.h b/contrib/tools/python3/src/Objects/clinic/listobject.c.h index c8094ee3b9..ed137c95a8 100644 --- a/contrib/tools/python3/src/Objects/clinic/listobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/listobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(list_insert__doc__, "Insert object before index."); #define LIST_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))list_insert, METH_FASTCALL, list_insert__doc__}, + {"insert", (PyCFunction)(void(*)(void))list_insert, METH_FASTCALL, list_insert__doc__}, static PyObject * list_insert_impl(PyListObject *self, Py_ssize_t index, PyObject *object); @@ -21,27 +21,27 @@ list_insert(PyListObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t index; PyObject *object; - if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { 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; - } - index = ival; - } - object = 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; + } + object = args[1]; return_value = list_insert_impl(self, index, object); exit: @@ -111,7 +111,7 @@ PyDoc_STRVAR(list_pop__doc__, "Raises IndexError if list is empty or index is out of range."); #define LIST_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))list_pop, METH_FASTCALL, list_pop__doc__}, + {"pop", (PyCFunction)(void(*)(void))list_pop, METH_FASTCALL, list_pop__doc__}, static PyObject * list_pop_impl(PyListObject *self, Py_ssize_t index); @@ -122,30 +122,30 @@ list_pop(PyListObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t index = -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; } - 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; - } - index = ival; - } -skip_optional: + { + 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; + } +skip_optional: return_value = list_pop_impl(self, index); exit: @@ -156,18 +156,18 @@ PyDoc_STRVAR(list_sort__doc__, "sort($self, /, *, key=None, reverse=False)\n" "--\n" "\n" -"Sort the list in ascending order and return None.\n" -"\n" -"The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n" -"order of two equal elements is maintained).\n" -"\n" -"If a key function is given, apply it once to each list item and sort them,\n" -"ascending or descending, according to their function values.\n" -"\n" -"The reverse flag can be set to sort in descending order."); +"Sort the list in ascending order and return None.\n" +"\n" +"The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n" +"order of two equal elements is maintained).\n" +"\n" +"If a key function is given, apply it once to each list item and sort them,\n" +"ascending or descending, according to their function values.\n" +"\n" +"The reverse flag can be set to sort in descending order."); #define LIST_SORT_METHODDEF \ - {"sort", (PyCFunction)(void(*)(void))list_sort, METH_FASTCALL|METH_KEYWORDS, list_sort__doc__}, + {"sort", (PyCFunction)(void(*)(void))list_sort, METH_FASTCALL|METH_KEYWORDS, list_sort__doc__}, static PyObject * list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse); @@ -177,35 +177,35 @@ list_sort(PyListObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "reverse", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "sort", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "sort", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *keyfunc = Py_None; int reverse = 0; - 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]) { - keyfunc = args[0]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - reverse = _PyLong_AsInt(args[1]); - if (reverse == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_kwonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + keyfunc = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + reverse = _PyLong_AsInt(args[1]); + if (reverse == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = list_sort_impl(self, keyfunc, reverse); exit: @@ -239,7 +239,7 @@ PyDoc_STRVAR(list_index__doc__, "Raises ValueError if the value is not present."); #define LIST_INDEX_METHODDEF \ - {"index", (PyCFunction)(void(*)(void))list_index, METH_FASTCALL, list_index__doc__}, + {"index", (PyCFunction)(void(*)(void))list_index, METH_FASTCALL, list_index__doc__}, static PyObject * list_index_impl(PyListObject *self, PyObject *value, Py_ssize_t start, @@ -253,23 +253,23 @@ list_index(PyListObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t start = 0; Py_ssize_t stop = PY_SSIZE_T_MAX; - if (!_PyArg_CheckPositional("index", nargs, 1, 3)) { + if (!_PyArg_CheckPositional("index", nargs, 1, 3)) { goto exit; } - value = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (!_PyEval_SliceIndexNotNone(args[1], &start)) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (!_PyEval_SliceIndexNotNone(args[2], &stop)) { - goto exit; - } -skip_optional: + value = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!_PyEval_SliceIndexNotNone(args[1], &start)) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!_PyEval_SliceIndexNotNone(args[2], &stop)) { + goto exit; + } +skip_optional: return_value = list_index_impl(self, value, start, stop); exit: @@ -314,18 +314,18 @@ list___init__(PyObject *self, PyObject *args, PyObject *kwargs) int return_value = -1; PyObject *iterable = NULL; - if (Py_IS_TYPE(self, &PyList_Type) && + if (Py_IS_TYPE(self, &PyList_Type) && !_PyArg_NoKeywords("list", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("list", PyTuple_GET_SIZE(args), 0, 1)) { + if (!_PyArg_CheckPositional("list", PyTuple_GET_SIZE(args), 0, 1)) { goto exit; } - if (PyTuple_GET_SIZE(args) < 1) { - goto skip_optional; - } - iterable = PyTuple_GET_ITEM(args, 0); -skip_optional: + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + iterable = PyTuple_GET_ITEM(args, 0); +skip_optional: return_value = list___init___impl((PyListObject *)self, iterable); exit: @@ -367,4 +367,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored)) { return list___reversed___impl(self); } -/*[clinic end generated code: output=1ff61490c091d165 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1ff61490c091d165 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/longobject.c.h b/contrib/tools/python3/src/Objects/clinic/longobject.c.h index 83db1f761a..27e8dfe935 100644 --- a/contrib/tools/python3/src/Objects/clinic/longobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/longobject.c.h @@ -10,29 +10,29 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "base", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "int", 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 _PyArg_Parser _parser = {NULL, _keywords, "int", 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 *x = NULL; PyObject *obase = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } - if (nargs < 1) { - goto skip_optional_posonly; - } - noptargs--; - x = fastargs[0]; -skip_optional_posonly: - if (!noptargs) { - goto skip_optional_pos; - } - obase = fastargs[1]; -skip_optional_pos: + if (nargs < 1) { + goto skip_optional_posonly; + } + noptargs--; + x = fastargs[0]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_pos; + } + obase = fastargs[1]; +skip_optional_pos: return_value = long_new_impl(type, x, obase); exit: @@ -73,14 +73,14 @@ int___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("__format__", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "argument", "str", arg); goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - format_spec = arg; + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + format_spec = arg; return_value = int___format___impl(self, format_spec); exit: @@ -138,34 +138,34 @@ int_bit_length(PyObject *self, PyObject *Py_UNUSED(ignored)) return int_bit_length_impl(self); } -PyDoc_STRVAR(int_as_integer_ratio__doc__, -"as_integer_ratio($self, /)\n" -"--\n" -"\n" -"Return integer ratio.\n" -"\n" -"Return a pair of integers, whose ratio is exactly equal to the original int\n" -"and with a positive denominator.\n" -"\n" -">>> (10).as_integer_ratio()\n" -"(10, 1)\n" -">>> (-10).as_integer_ratio()\n" -"(-10, 1)\n" -">>> (0).as_integer_ratio()\n" -"(0, 1)"); - -#define INT_AS_INTEGER_RATIO_METHODDEF \ - {"as_integer_ratio", (PyCFunction)int_as_integer_ratio, METH_NOARGS, int_as_integer_ratio__doc__}, - -static PyObject * -int_as_integer_ratio_impl(PyObject *self); - -static PyObject * -int_as_integer_ratio(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - return int_as_integer_ratio_impl(self); -} - +PyDoc_STRVAR(int_as_integer_ratio__doc__, +"as_integer_ratio($self, /)\n" +"--\n" +"\n" +"Return integer ratio.\n" +"\n" +"Return a pair of integers, whose ratio is exactly equal to the original int\n" +"and with a positive denominator.\n" +"\n" +">>> (10).as_integer_ratio()\n" +"(10, 1)\n" +">>> (-10).as_integer_ratio()\n" +"(-10, 1)\n" +">>> (0).as_integer_ratio()\n" +"(0, 1)"); + +#define INT_AS_INTEGER_RATIO_METHODDEF \ + {"as_integer_ratio", (PyCFunction)int_as_integer_ratio, METH_NOARGS, int_as_integer_ratio__doc__}, + +static PyObject * +int_as_integer_ratio_impl(PyObject *self); + +static PyObject * +int_as_integer_ratio(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return int_as_integer_ratio_impl(self); +} + PyDoc_STRVAR(int_to_bytes__doc__, "to_bytes($self, /, length, byteorder, *, signed=False)\n" "--\n" @@ -187,7 +187,7 @@ PyDoc_STRVAR(int_to_bytes__doc__, " is raised."); #define INT_TO_BYTES_METHODDEF \ - {"to_bytes", (PyCFunction)(void(*)(void))int_to_bytes, METH_FASTCALL|METH_KEYWORDS, int_to_bytes__doc__}, + {"to_bytes", (PyCFunction)(void(*)(void))int_to_bytes, METH_FASTCALL|METH_KEYWORDS, int_to_bytes__doc__}, static PyObject * int_to_bytes_impl(PyObject *self, Py_ssize_t length, PyObject *byteorder, @@ -198,50 +198,50 @@ int_to_bytes(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"length", "byteorder", "signed", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "to_bytes", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "to_bytes", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; Py_ssize_t length; PyObject *byteorder; int is_signed = 0; - 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_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; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("to_bytes", "argument 'byteorder'", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - byteorder = args[1]; - if (!noptargs) { - goto skip_optional_kwonly; - } - is_signed = PyObject_IsTrue(args[2]); - if (is_signed < 0) { - goto exit; - } -skip_optional_kwonly: + 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; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("to_bytes", "argument 'byteorder'", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + byteorder = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + is_signed = PyObject_IsTrue(args[2]); + if (is_signed < 0) { + goto exit; + } +skip_optional_kwonly: return_value = int_to_bytes_impl(self, length, byteorder, is_signed); exit: @@ -269,7 +269,7 @@ PyDoc_STRVAR(int_from_bytes__doc__, " Indicates whether two\'s complement is used to represent the integer."); #define INT_FROM_BYTES_METHODDEF \ - {"from_bytes", (PyCFunction)(void(*)(void))int_from_bytes, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, int_from_bytes__doc__}, + {"from_bytes", (PyCFunction)(void(*)(void))int_from_bytes, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, int_from_bytes__doc__}, static PyObject * int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj, @@ -280,37 +280,37 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"bytes", "byteorder", "signed", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "from_bytes", 0}; - PyObject *argsbuf[3]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "from_bytes", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *bytes_obj; PyObject *byteorder; int is_signed = 0; - 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; + } + bytes_obj = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("from_bytes", "argument 'byteorder'", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + byteorder = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + is_signed = PyObject_IsTrue(args[2]); + if (is_signed < 0) { goto exit; } - bytes_obj = args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("from_bytes", "argument 'byteorder'", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - byteorder = args[1]; - if (!noptargs) { - goto skip_optional_kwonly; - } - is_signed = PyObject_IsTrue(args[2]); - if (is_signed < 0) { - goto exit; - } -skip_optional_kwonly: +skip_optional_kwonly: return_value = int_from_bytes_impl(type, bytes_obj, byteorder, is_signed); exit: return return_value; } -/*[clinic end generated code: output=77bc3b2615822cb8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=77bc3b2615822cb8 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/memoryobject.c.h b/contrib/tools/python3/src/Objects/clinic/memoryobject.c.h index 3cd265fb8d..75ac201126 100644 --- a/contrib/tools/python3/src/Objects/clinic/memoryobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/memoryobject.c.h @@ -1,74 +1,74 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(memoryview_hex__doc__, -"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" -"--\n" -"\n" -"Return the data in the buffer as a str of hexadecimal numbers.\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" -"Example:\n" -">>> value = memoryview(b\'\\xb9\\x01\\xef\')\n" -">>> value.hex()\n" -"\'b901ef\'\n" -">>> value.hex(\':\')\n" -"\'b9:01:ef\'\n" -">>> value.hex(\':\', 2)\n" -"\'b9:01ef\'\n" -">>> value.hex(\':\', -2)\n" -"\'b901:ef\'"); - -#define MEMORYVIEW_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))memoryview_hex, METH_FASTCALL|METH_KEYWORDS, memoryview_hex__doc__}, - -static PyObject * -memoryview_hex_impl(PyMemoryViewObject *self, PyObject *sep, - int bytes_per_sep); - -static PyObject * -memoryview_hex(PyMemoryViewObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject *sep = NULL; - int bytes_per_sep = 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]) { - sep = args[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - bytes_per_sep = _PyLong_AsInt(args[1]); - if (bytes_per_sep == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = memoryview_hex_impl(self, sep, bytes_per_sep); - -exit: - return return_value; -} -/*[clinic end generated code: output=ee265a73f68b0077 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(memoryview_hex__doc__, +"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n" +"--\n" +"\n" +"Return the data in the buffer as a str of hexadecimal numbers.\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" +"Example:\n" +">>> value = memoryview(b\'\\xb9\\x01\\xef\')\n" +">>> value.hex()\n" +"\'b901ef\'\n" +">>> value.hex(\':\')\n" +"\'b9:01:ef\'\n" +">>> value.hex(\':\', 2)\n" +"\'b9:01ef\'\n" +">>> value.hex(\':\', -2)\n" +"\'b901:ef\'"); + +#define MEMORYVIEW_HEX_METHODDEF \ + {"hex", (PyCFunction)(void(*)(void))memoryview_hex, METH_FASTCALL|METH_KEYWORDS, memoryview_hex__doc__}, + +static PyObject * +memoryview_hex_impl(PyMemoryViewObject *self, PyObject *sep, + int bytes_per_sep); + +static PyObject * +memoryview_hex(PyMemoryViewObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sep", "bytes_per_sep", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "hex", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *sep = NULL; + int bytes_per_sep = 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]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + bytes_per_sep = _PyLong_AsInt(args[1]); + if (bytes_per_sep == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = memoryview_hex_impl(self, sep, bytes_per_sep); + +exit: + return return_value; +} +/*[clinic end generated code: output=ee265a73f68b0077 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/moduleobject.c.h b/contrib/tools/python3/src/Objects/clinic/moduleobject.c.h index ad659231fa..c1534eaee2 100644 --- a/contrib/tools/python3/src/Objects/clinic/moduleobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/moduleobject.c.h @@ -18,34 +18,34 @@ module___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"name", "doc", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "module", 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; + static _PyArg_Parser _parser = {NULL, _keywords, "module", 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 *name; PyObject *doc = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!PyUnicode_Check(fastargs[0])) { - _PyArg_BadArgument("module", "argument 'name'", "str", fastargs[0]); - goto exit; - } - if (PyUnicode_READY(fastargs[0]) == -1) { - goto exit; - } - name = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - doc = fastargs[1]; -skip_optional_pos: + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("module", "argument 'name'", "str", fastargs[0]); + goto exit; + } + if (PyUnicode_READY(fastargs[0]) == -1) { + goto exit; + } + name = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + doc = fastargs[1]; +skip_optional_pos: return_value = module___init___impl((PyModuleObject *)self, name, doc); exit: return return_value; } -/*[clinic end generated code: output=680276bc3a496d7a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=680276bc3a496d7a input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/odictobject.c.h b/contrib/tools/python3/src/Objects/clinic/odictobject.c.h index 38b0e3b22a..f43bc14ce1 100644 --- a/contrib/tools/python3/src/Objects/clinic/odictobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/odictobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(OrderedDict_fromkeys__doc__, "Create a new ordered dictionary with keys from iterable and values set to value."); #define ORDEREDDICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)(void(*)(void))OrderedDict_fromkeys, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, OrderedDict_fromkeys__doc__}, + {"fromkeys", (PyCFunction)(void(*)(void))OrderedDict_fromkeys, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, OrderedDict_fromkeys__doc__}, static PyObject * OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value); @@ -19,22 +19,22 @@ OrderedDict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "value", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "fromkeys", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "fromkeys", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *seq; PyObject *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; } - seq = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - value = args[1]; -skip_optional_pos: + seq = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + value = args[1]; +skip_optional_pos: return_value = OrderedDict_fromkeys_impl(type, seq, value); exit: @@ -50,7 +50,7 @@ PyDoc_STRVAR(OrderedDict_setdefault__doc__, "Return the value for key if key is in the dictionary, else default."); #define ORDEREDDICT_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))OrderedDict_setdefault, METH_FASTCALL|METH_KEYWORDS, OrderedDict_setdefault__doc__}, + {"setdefault", (PyCFunction)(void(*)(void))OrderedDict_setdefault, METH_FASTCALL|METH_KEYWORDS, OrderedDict_setdefault__doc__}, static PyObject * OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key, @@ -61,22 +61,22 @@ OrderedDict_setdefault(PyODictObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "default", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "setdefault", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "setdefault", 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 = OrderedDict_setdefault_impl(self, key, default_value); exit: @@ -92,7 +92,7 @@ PyDoc_STRVAR(OrderedDict_popitem__doc__, "Pairs are returned in LIFO order if last is true or FIFO order if false."); #define ORDEREDDICT_POPITEM_METHODDEF \ - {"popitem", (PyCFunction)(void(*)(void))OrderedDict_popitem, METH_FASTCALL|METH_KEYWORDS, OrderedDict_popitem__doc__}, + {"popitem", (PyCFunction)(void(*)(void))OrderedDict_popitem, METH_FASTCALL|METH_KEYWORDS, OrderedDict_popitem__doc__}, static PyObject * OrderedDict_popitem_impl(PyODictObject *self, int last); @@ -102,23 +102,23 @@ OrderedDict_popitem(PyODictObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"last", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "popitem", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "popitem", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int last = 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; + } + last = PyObject_IsTrue(args[0]); + if (last < 0) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - last = PyObject_IsTrue(args[0]); - if (last < 0) { - goto exit; - } -skip_optional_pos: +skip_optional_pos: return_value = OrderedDict_popitem_impl(self, last); exit: @@ -134,7 +134,7 @@ PyDoc_STRVAR(OrderedDict_move_to_end__doc__, "Raise KeyError if the element does not exist."); #define ORDEREDDICT_MOVE_TO_END_METHODDEF \ - {"move_to_end", (PyCFunction)(void(*)(void))OrderedDict_move_to_end, METH_FASTCALL|METH_KEYWORDS, OrderedDict_move_to_end__doc__}, + {"move_to_end", (PyCFunction)(void(*)(void))OrderedDict_move_to_end, METH_FASTCALL|METH_KEYWORDS, OrderedDict_move_to_end__doc__}, static PyObject * OrderedDict_move_to_end_impl(PyODictObject *self, PyObject *key, int last); @@ -144,28 +144,28 @@ OrderedDict_move_to_end(PyODictObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "last", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "move_to_end", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "move_to_end", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *key; int last = 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; + } + key = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + last = PyObject_IsTrue(args[1]); + if (last < 0) { goto exit; } - key = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - last = PyObject_IsTrue(args[1]); - if (last < 0) { - goto exit; - } -skip_optional_pos: +skip_optional_pos: return_value = OrderedDict_move_to_end_impl(self, key, last); exit: return return_value; } -/*[clinic end generated code: output=8eb1296df9142908 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8eb1296df9142908 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/structseq.c.h b/contrib/tools/python3/src/Objects/clinic/structseq.c.h index c2c952fa2c..b3b4836543 100644 --- a/contrib/tools/python3/src/Objects/clinic/structseq.c.h +++ b/contrib/tools/python3/src/Objects/clinic/structseq.c.h @@ -10,27 +10,27 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sequence", "dict", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "structseq", 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; + static _PyArg_Parser _parser = {NULL, _keywords, "structseq", 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 *arg; PyObject *dict = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } - arg = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - dict = fastargs[1]; -skip_optional_pos: + arg = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + dict = fastargs[1]; +skip_optional_pos: return_value = structseq_new_impl(type, arg, dict); exit: return return_value; } -/*[clinic end generated code: output=ed3019acf49b656c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ed3019acf49b656c input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/tupleobject.c.h b/contrib/tools/python3/src/Objects/clinic/tupleobject.c.h index 1184a161a7..fe2fae42ee 100644 --- a/contrib/tools/python3/src/Objects/clinic/tupleobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/tupleobject.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(tuple_index__doc__, "Raises ValueError if the value is not present."); #define TUPLE_INDEX_METHODDEF \ - {"index", (PyCFunction)(void(*)(void))tuple_index, METH_FASTCALL, tuple_index__doc__}, + {"index", (PyCFunction)(void(*)(void))tuple_index, METH_FASTCALL, tuple_index__doc__}, static PyObject * tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start, @@ -25,23 +25,23 @@ tuple_index(PyTupleObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t start = 0; Py_ssize_t stop = PY_SSIZE_T_MAX; - if (!_PyArg_CheckPositional("index", nargs, 1, 3)) { + if (!_PyArg_CheckPositional("index", nargs, 1, 3)) { goto exit; } - value = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (!_PyEval_SliceIndexNotNone(args[1], &start)) { - goto exit; - } - if (nargs < 3) { - goto skip_optional; - } - if (!_PyEval_SliceIndexNotNone(args[2], &stop)) { - goto exit; - } -skip_optional: + value = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!_PyEval_SliceIndexNotNone(args[1], &start)) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!_PyEval_SliceIndexNotNone(args[2], &stop)) { + goto exit; + } +skip_optional: return_value = tuple_index_impl(self, value, start, stop); exit: @@ -81,14 +81,14 @@ tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("tuple", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) { + if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) { goto exit; } - if (PyTuple_GET_SIZE(args) < 1) { - goto skip_optional; - } - iterable = PyTuple_GET_ITEM(args, 0); -skip_optional: + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + iterable = PyTuple_GET_ITEM(args, 0); +skip_optional: return_value = tuple_new_impl(type, iterable); exit: @@ -111,4 +111,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored)) { return tuple___getnewargs___impl(self); } -/*[clinic end generated code: output=56fab9b7368aba49 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=56fab9b7368aba49 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/typeobject.c.h b/contrib/tools/python3/src/Objects/clinic/typeobject.c.h index 3f0b9b604c..357eb44b12 100644 --- a/contrib/tools/python3/src/Objects/clinic/typeobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/typeobject.c.h @@ -166,15 +166,15 @@ object___reduce_ex__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int protocol; - 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; + } + protocol = _PyLong_AsInt(arg); + if (protocol == -1 && PyErr_Occurred()) { goto exit; } - protocol = _PyLong_AsInt(arg); - if (protocol == -1 && PyErr_Occurred()) { - goto exit; - } return_value = object___reduce_ex___impl(self, protocol); exit: @@ -199,14 +199,14 @@ object___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("__format__", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - format_spec = arg; + format_spec = arg; return_value = object___format___impl(self, format_spec); exit: @@ -248,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return object___dir___impl(self); } -/*[clinic end generated code: output=7a6d272d282308f3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7a6d272d282308f3 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h b/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h index 892d9ba134..cf81df4af6 100644 --- a/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h +++ b/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h @@ -71,7 +71,7 @@ PyDoc_STRVAR(unicode_center__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_CENTER_METHODDEF \ - {"center", (PyCFunction)(void(*)(void))unicode_center, METH_FASTCALL, unicode_center__doc__}, + {"center", (PyCFunction)(void(*)(void))unicode_center, METH_FASTCALL, unicode_center__doc__}, static PyObject * unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -83,33 +83,33 @@ unicode_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!_PyArg_CheckPositional("center", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("center", nargs, 1, 2)) { 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; - } - width = ival; - } - if (nargs < 2) { - goto skip_optional; - } - if (!convert_uc(args[1], &fillchar)) { - goto exit; - } -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; + } + width = ival; + } + if (nargs < 2) { + goto skip_optional; + } + if (!convert_uc(args[1], &fillchar)) { + goto exit; + } +skip_optional: return_value = unicode_center_impl(self, width, fillchar); exit: @@ -132,7 +132,7 @@ PyDoc_STRVAR(unicode_encode__doc__, " codecs.register_error that can handle UnicodeEncodeErrors."); #define UNICODE_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))unicode_encode, METH_FASTCALL|METH_KEYWORDS, unicode_encode__doc__}, + {"encode", (PyCFunction)(void(*)(void))unicode_encode, METH_FASTCALL|METH_KEYWORDS, unicode_encode__doc__}, static PyObject * unicode_encode_impl(PyObject *self, const char *encoding, const char *errors); @@ -142,51 +142,51 @@ unicode_encode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = NULL; - 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]) { - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[0]); - goto exit; - } - 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; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("encode", "argument 'errors'", "str", args[1]); - goto exit; - } - 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; - } -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[0]); + goto exit; + } + 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; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("encode", "argument 'errors'", "str", args[1]); + goto exit; + } + 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; + } +skip_optional_pos: return_value = unicode_encode_impl(self, encoding, errors); exit: @@ -202,7 +202,7 @@ PyDoc_STRVAR(unicode_expandtabs__doc__, "If tabsize is not given, a tab size of 8 characters is assumed."); #define UNICODE_EXPANDTABS_METHODDEF \ - {"expandtabs", (PyCFunction)(void(*)(void))unicode_expandtabs, METH_FASTCALL|METH_KEYWORDS, unicode_expandtabs__doc__}, + {"expandtabs", (PyCFunction)(void(*)(void))unicode_expandtabs, METH_FASTCALL|METH_KEYWORDS, unicode_expandtabs__doc__}, static PyObject * unicode_expandtabs_impl(PyObject *self, int tabsize); @@ -212,28 +212,28 @@ unicode_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"tabsize", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "expandtabs", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "expandtabs", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int tabsize = 8; - 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; - } - tabsize = _PyLong_AsInt(args[0]); - if (tabsize == -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; + } + tabsize = _PyLong_AsInt(args[0]); + if (tabsize == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = unicode_expandtabs_impl(self, tabsize); exit: @@ -456,8 +456,8 @@ PyDoc_STRVAR(unicode_isidentifier__doc__, "\n" "Return True if the string is a valid Python identifier, False otherwise.\n" "\n" -"Call keyword.iskeyword(s) to test whether string s is a reserved identifier,\n" -"such as \"def\" or \"class\"."); +"Call keyword.iskeyword(s) to test whether string s is a reserved identifier,\n" +"such as \"def\" or \"class\"."); #define UNICODE_ISIDENTIFIER_METHODDEF \ {"isidentifier", (PyCFunction)unicode_isidentifier, METH_NOARGS, unicode_isidentifier__doc__}, @@ -515,7 +515,7 @@ PyDoc_STRVAR(unicode_ljust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_LJUST_METHODDEF \ - {"ljust", (PyCFunction)(void(*)(void))unicode_ljust, METH_FASTCALL, unicode_ljust__doc__}, + {"ljust", (PyCFunction)(void(*)(void))unicode_ljust, METH_FASTCALL, unicode_ljust__doc__}, static PyObject * unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -527,33 +527,33 @@ unicode_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) { + 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; + } + width = ival; + } + if (nargs < 2) { + goto skip_optional; + } + if (!convert_uc(args[1], &fillchar)) { 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; - } - width = ival; - } - if (nargs < 2) { - goto skip_optional; - } - if (!convert_uc(args[1], &fillchar)) { - goto exit; - } -skip_optional: +skip_optional: return_value = unicode_ljust_impl(self, width, fillchar); exit: @@ -582,12 +582,12 @@ PyDoc_STRVAR(unicode_strip__doc__, "strip($self, chars=None, /)\n" "--\n" "\n" -"Return a copy of the string with leading and trailing whitespace removed.\n" +"Return a copy of the string with leading and trailing whitespace removed.\n" "\n" "If chars is given and not None, remove characters in chars instead."); #define UNICODE_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))unicode_strip, METH_FASTCALL, unicode_strip__doc__}, + {"strip", (PyCFunction)(void(*)(void))unicode_strip, METH_FASTCALL, unicode_strip__doc__}, static PyObject * unicode_strip_impl(PyObject *self, PyObject *chars); @@ -598,14 +598,14 @@ unicode_strip(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *chars = Py_None; - if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - chars = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + chars = args[0]; +skip_optional: return_value = unicode_strip_impl(self, chars); exit: @@ -621,7 +621,7 @@ PyDoc_STRVAR(unicode_lstrip__doc__, "If chars is given and not None, remove characters in chars instead."); #define UNICODE_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))unicode_lstrip, METH_FASTCALL, unicode_lstrip__doc__}, + {"lstrip", (PyCFunction)(void(*)(void))unicode_lstrip, METH_FASTCALL, unicode_lstrip__doc__}, static PyObject * unicode_lstrip_impl(PyObject *self, PyObject *chars); @@ -630,16 +630,16 @@ static PyObject * unicode_lstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *chars = Py_None; + PyObject *chars = Py_None; - if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - chars = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + chars = args[0]; +skip_optional: return_value = unicode_lstrip_impl(self, chars); exit: @@ -655,7 +655,7 @@ PyDoc_STRVAR(unicode_rstrip__doc__, "If chars is given and not None, remove characters in chars instead."); #define UNICODE_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))unicode_rstrip, METH_FASTCALL, unicode_rstrip__doc__}, + {"rstrip", (PyCFunction)(void(*)(void))unicode_rstrip, METH_FASTCALL, unicode_rstrip__doc__}, static PyObject * unicode_rstrip_impl(PyObject *self, PyObject *chars); @@ -664,16 +664,16 @@ static PyObject * unicode_rstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *chars = Py_None; + PyObject *chars = Py_None; - if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - chars = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + chars = args[0]; +skip_optional: return_value = unicode_rstrip_impl(self, chars); exit: @@ -694,7 +694,7 @@ PyDoc_STRVAR(unicode_replace__doc__, "replaced."); #define UNICODE_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))unicode_replace, METH_FASTCALL, unicode_replace__doc__}, + {"replace", (PyCFunction)(void(*)(void))unicode_replace, METH_FASTCALL, unicode_replace__doc__}, static PyObject * unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new, @@ -708,123 +708,123 @@ unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *new; Py_ssize_t count = -1; - if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { + if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("replace", "argument 1", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + old = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("replace", "argument 2", "str", args[1]); goto exit; } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("replace", "argument 1", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - old = args[0]; - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("replace", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - new = args[1]; - if (nargs < 3) { - goto skip_optional; - } - 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: + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + new = args[1]; + if (nargs < 3) { + goto skip_optional; + } + 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: return_value = unicode_replace_impl(self, old, new, count); exit: return return_value; } -PyDoc_STRVAR(unicode_removeprefix__doc__, -"removeprefix($self, prefix, /)\n" -"--\n" -"\n" -"Return a str with the given prefix string removed if present.\n" -"\n" -"If the string starts with the prefix string, return string[len(prefix):].\n" -"Otherwise, return a copy of the original string."); - -#define UNICODE_REMOVEPREFIX_METHODDEF \ - {"removeprefix", (PyCFunction)unicode_removeprefix, METH_O, unicode_removeprefix__doc__}, - -static PyObject * -unicode_removeprefix_impl(PyObject *self, PyObject *prefix); - -static PyObject * -unicode_removeprefix(PyObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - PyObject *prefix; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("removeprefix", "argument", "str", arg); - goto exit; - } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - prefix = arg; - return_value = unicode_removeprefix_impl(self, prefix); - -exit: - return return_value; -} - -PyDoc_STRVAR(unicode_removesuffix__doc__, -"removesuffix($self, suffix, /)\n" -"--\n" -"\n" -"Return a str with the given suffix string removed if present.\n" -"\n" -"If the string ends with the suffix string and that suffix is not empty,\n" -"return string[:-len(suffix)]. Otherwise, return a copy of the original\n" -"string."); - -#define UNICODE_REMOVESUFFIX_METHODDEF \ - {"removesuffix", (PyCFunction)unicode_removesuffix, METH_O, unicode_removesuffix__doc__}, - -static PyObject * -unicode_removesuffix_impl(PyObject *self, PyObject *suffix); - -static PyObject * -unicode_removesuffix(PyObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - PyObject *suffix; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("removesuffix", "argument", "str", arg); - goto exit; - } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - suffix = arg; - return_value = unicode_removesuffix_impl(self, suffix); - -exit: - return return_value; -} - +PyDoc_STRVAR(unicode_removeprefix__doc__, +"removeprefix($self, prefix, /)\n" +"--\n" +"\n" +"Return a str with the given prefix string removed if present.\n" +"\n" +"If the string starts with the prefix string, return string[len(prefix):].\n" +"Otherwise, return a copy of the original string."); + +#define UNICODE_REMOVEPREFIX_METHODDEF \ + {"removeprefix", (PyCFunction)unicode_removeprefix, METH_O, unicode_removeprefix__doc__}, + +static PyObject * +unicode_removeprefix_impl(PyObject *self, PyObject *prefix); + +static PyObject * +unicode_removeprefix(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *prefix; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("removeprefix", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + prefix = arg; + return_value = unicode_removeprefix_impl(self, prefix); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_removesuffix__doc__, +"removesuffix($self, suffix, /)\n" +"--\n" +"\n" +"Return a str with the given suffix string removed if present.\n" +"\n" +"If the string ends with the suffix string and that suffix is not empty,\n" +"return string[:-len(suffix)]. Otherwise, return a copy of the original\n" +"string."); + +#define UNICODE_REMOVESUFFIX_METHODDEF \ + {"removesuffix", (PyCFunction)unicode_removesuffix, METH_O, unicode_removesuffix__doc__}, + +static PyObject * +unicode_removesuffix_impl(PyObject *self, PyObject *suffix); + +static PyObject * +unicode_removesuffix(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *suffix; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("removesuffix", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { + goto exit; + } + suffix = arg; + return_value = unicode_removesuffix_impl(self, suffix); + +exit: + return return_value; +} + PyDoc_STRVAR(unicode_rjust__doc__, "rjust($self, width, fillchar=\' \', /)\n" "--\n" @@ -834,7 +834,7 @@ PyDoc_STRVAR(unicode_rjust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_RJUST_METHODDEF \ - {"rjust", (PyCFunction)(void(*)(void))unicode_rjust, METH_FASTCALL, unicode_rjust__doc__}, + {"rjust", (PyCFunction)(void(*)(void))unicode_rjust, METH_FASTCALL, unicode_rjust__doc__}, static PyObject * unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -846,33 +846,33 @@ unicode_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) { + 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; + } + width = ival; + } + if (nargs < 2) { + goto skip_optional; + } + if (!convert_uc(args[1], &fillchar)) { 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; - } - width = ival; - } - if (nargs < 2) { - goto skip_optional; - } - if (!convert_uc(args[1], &fillchar)) { - goto exit; - } -skip_optional: +skip_optional: return_value = unicode_rjust_impl(self, width, fillchar); exit: @@ -894,7 +894,7 @@ PyDoc_STRVAR(unicode_split__doc__, " -1 (the default value) means no limit."); #define UNICODE_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__}, + {"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__}, static PyObject * unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -904,43 +904,43 @@ unicode_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - 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]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (args[0]) { - sep = 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: + { + 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 = unicode_split_impl(self, sep, maxsplit); exit: @@ -996,7 +996,7 @@ PyDoc_STRVAR(unicode_rsplit__doc__, "Splits are done starting at the end of the string and working to the front."); #define UNICODE_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__}, + {"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__}, static PyObject * unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -1006,43 +1006,43 @@ unicode_rsplit(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - 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]) { - sep = 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: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = 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 = unicode_rsplit_impl(self, sep, maxsplit); exit: @@ -1059,7 +1059,7 @@ PyDoc_STRVAR(unicode_splitlines__doc__, "true."); #define UNICODE_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))unicode_splitlines, METH_FASTCALL|METH_KEYWORDS, unicode_splitlines__doc__}, + {"splitlines", (PyCFunction)(void(*)(void))unicode_splitlines, METH_FASTCALL|METH_KEYWORDS, unicode_splitlines__doc__}, static PyObject * unicode_splitlines_impl(PyObject *self, int keepends); @@ -1069,28 +1069,28 @@ unicode_splitlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - 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; - } - keepends = _PyLong_AsInt(args[0]); - if (keepends == -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; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = unicode_splitlines_impl(self, keepends); exit: @@ -1116,7 +1116,7 @@ unicode_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(unicode_maketrans__doc__, -"maketrans(x, y=<unrepresentable>, z=<unrepresentable>, /)\n" +"maketrans(x, y=<unrepresentable>, z=<unrepresentable>, /)\n" "--\n" "\n" "Return a translation table usable for str.translate().\n" @@ -1130,7 +1130,7 @@ PyDoc_STRVAR(unicode_maketrans__doc__, "must be a string, whose characters will be mapped to None in the result."); #define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, + {"maketrans", (PyCFunction)(void(*)(void))unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); @@ -1143,33 +1143,33 @@ unicode_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs) PyObject *y = NULL; PyObject *z = NULL; - if (!_PyArg_CheckPositional("maketrans", nargs, 1, 3)) { + if (!_PyArg_CheckPositional("maketrans", nargs, 1, 3)) { + goto exit; + } + x = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("maketrans", "argument 2", "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + y = args[1]; + if (nargs < 3) { + goto skip_optional; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("maketrans", "argument 3", "str", args[2]); + goto exit; + } + if (PyUnicode_READY(args[2]) == -1) { goto exit; } - x = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("maketrans", "argument 2", "str", args[1]); - goto exit; - } - if (PyUnicode_READY(args[1]) == -1) { - goto exit; - } - y = args[1]; - if (nargs < 3) { - goto skip_optional; - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("maketrans", "argument 3", "str", args[2]); - goto exit; - } - if (PyUnicode_READY(args[2]) == -1) { - goto exit; - } - z = args[2]; -skip_optional: + z = args[2]; +skip_optional: return_value = unicode_maketrans_impl(x, y, z); exit: @@ -1231,23 +1231,23 @@ unicode_zfill(PyObject *self, PyObject *arg) PyObject *return_value = NULL; Py_ssize_t width; - 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; } - { - 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; - } - width = ival; - } + { + 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; + } + width = ival; + } return_value = unicode_zfill_impl(self, width); exit: @@ -1272,14 +1272,14 @@ unicode___format__(PyObject *self, PyObject *arg) PyObject *return_value = NULL; PyObject *format_spec; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("__format__", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("__format__", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - format_spec = arg; + format_spec = arg; return_value = unicode___format___impl(self, format_spec); exit: @@ -1303,4 +1303,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) { return unicode_sizeof_impl(self); } -/*[clinic end generated code: output=b91233f3722643be input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b91233f3722643be input=a9049054013a1b77]*/ |