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/Modules/_io/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/Modules/_io/clinic')
8 files changed, 1007 insertions, 1007 deletions
diff --git a/contrib/tools/python3/src/Modules/_io/clinic/_iomodule.c.h b/contrib/tools/python3/src/Modules/_io/clinic/_iomodule.c.h index bd460e81a1..1a9651d340 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/_iomodule.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/_iomodule.c.h @@ -127,7 +127,7 @@ PyDoc_STRVAR(_io_open__doc__, "opened in a binary mode."); #define _IO_OPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))_io_open, METH_FASTCALL|METH_KEYWORDS, _io_open__doc__}, + {"open", (PyCFunction)(void(*)(void))_io_open, METH_FASTCALL|METH_KEYWORDS, _io_open__doc__}, static PyObject * _io_open_impl(PyObject *module, PyObject *file, const char *mode, @@ -139,9 +139,9 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; - PyObject *argsbuf[8]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; + PyObject *argsbuf[8]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *file; const char *mode = "r"; int buffering = -1; @@ -151,176 +151,176 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw int closefd = 1; PyObject *opener = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 8, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 8, 0, argsbuf); + if (!args) { goto exit; } - file = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (args[1]) { - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("open", "argument 'mode'", "str", args[1]); - goto exit; - } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length); - if (mode == NULL) { - goto exit; - } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[2]) { - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - buffering = _PyLong_AsInt(args[2]); - if (buffering == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[3]) { - if (args[3] == Py_None) { - encoding = NULL; - } - else if (PyUnicode_Check(args[3])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[3], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("open", "argument 'encoding'", "str or None", args[3]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[4]) { - if (args[4] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[4])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[4], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("open", "argument 'errors'", "str or None", args[4]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[5]) { - if (args[5] == Py_None) { - newline = NULL; - } - else if (PyUnicode_Check(args[5])) { - Py_ssize_t newline_length; - newline = PyUnicode_AsUTF8AndSize(args[5], &newline_length); - if (newline == NULL) { - goto exit; - } - if (strlen(newline) != (size_t)newline_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("open", "argument 'newline'", "str or None", args[5]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (args[6]) { - if (PyFloat_Check(args[6])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - closefd = _PyLong_AsInt(args[6]); - if (closefd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - opener = args[7]; -skip_optional_pos: + file = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("open", "argument 'mode'", "str", args[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + buffering = _PyLong_AsInt(args[2]); + if (buffering == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + if (args[3] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(args[3])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[3], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", "argument 'encoding'", "str or None", args[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + if (args[4] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[4])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[4], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", "argument 'errors'", "str or None", args[4]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + if (args[5] == Py_None) { + newline = NULL; + } + else if (PyUnicode_Check(args[5])) { + Py_ssize_t newline_length; + newline = PyUnicode_AsUTF8AndSize(args[5], &newline_length); + if (newline == NULL) { + goto exit; + } + if (strlen(newline) != (size_t)newline_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", "argument 'newline'", "str or None", args[5]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(args[6]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = args[7]; +skip_optional_pos: return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener); exit: return return_value; } - -PyDoc_STRVAR(_io_open_code__doc__, -"open_code($module, /, path)\n" -"--\n" -"\n" -"Opens the provided file with the intent to import the contents.\n" -"\n" -"This may perform extra validation beyond open(), but is otherwise interchangeable\n" -"with calling open(path, \'rb\')."); - -#define _IO_OPEN_CODE_METHODDEF \ - {"open_code", (PyCFunction)(void(*)(void))_io_open_code, METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__}, - -static PyObject * -_io_open_code_impl(PyObject *module, PyObject *path); - -static PyObject * -_io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "open_code", 0}; - PyObject *argsbuf[1]; - PyObject *path; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("open_code", "argument 'path'", "str", args[0]); - goto exit; - } - if (PyUnicode_READY(args[0]) == -1) { - goto exit; - } - path = args[0]; - return_value = _io_open_code_impl(module, path); - -exit: - return return_value; -} -/*[clinic end generated code: output=3df6bc6d91697545 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_io_open_code__doc__, +"open_code($module, /, path)\n" +"--\n" +"\n" +"Opens the provided file with the intent to import the contents.\n" +"\n" +"This may perform extra validation beyond open(), but is otherwise interchangeable\n" +"with calling open(path, \'rb\')."); + +#define _IO_OPEN_CODE_METHODDEF \ + {"open_code", (PyCFunction)(void(*)(void))_io_open_code, METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__}, + +static PyObject * +_io_open_code_impl(PyObject *module, PyObject *path); + +static PyObject * +_io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"path", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "open_code", 0}; + PyObject *argsbuf[1]; + PyObject *path; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("open_code", "argument 'path'", "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + path = args[0]; + return_value = _io_open_code_impl(module, path); + +exit: + return return_value; +} +/*[clinic end generated code: output=3df6bc6d91697545 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/bufferedio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/bufferedio.c.h index 4e3b6ab3d7..56d6332a25 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/bufferedio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/bufferedio.c.h @@ -19,15 +19,15 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__BufferedIOBase_readinto_impl(self, &buffer); exit: @@ -56,15 +56,15 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer); exit: @@ -103,7 +103,7 @@ PyDoc_STRVAR(_io__Buffered_peek__doc__, "\n"); #define _IO__BUFFERED_PEEK_METHODDEF \ - {"peek", (PyCFunction)(void(*)(void))_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__}, + {"peek", (PyCFunction)(void(*)(void))_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__}, static PyObject * _io__Buffered_peek_impl(buffered *self, Py_ssize_t size); @@ -114,30 +114,30 @@ _io__Buffered_peek(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = 0; - if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("peek", 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; - } - size = 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; + } + size = ival; + } +skip_optional: return_value = _io__Buffered_peek_impl(self, size); exit: @@ -150,7 +150,7 @@ PyDoc_STRVAR(_io__Buffered_read__doc__, "\n"); #define _IO__BUFFERED_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__}, static PyObject * _io__Buffered_read_impl(buffered *self, Py_ssize_t n); @@ -161,16 +161,16 @@ _io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io__Buffered_read_impl(self, n); exit: @@ -183,7 +183,7 @@ PyDoc_STRVAR(_io__Buffered_read1__doc__, "\n"); #define _IO__BUFFERED_READ1_METHODDEF \ - {"read1", (PyCFunction)(void(*)(void))_io__Buffered_read1, METH_FASTCALL, _io__Buffered_read1__doc__}, + {"read1", (PyCFunction)(void(*)(void))_io__Buffered_read1, METH_FASTCALL, _io__Buffered_read1__doc__}, static PyObject * _io__Buffered_read1_impl(buffered *self, Py_ssize_t n); @@ -194,30 +194,30 @@ _io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - n = ival; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + n = ival; + } +skip_optional: return_value = _io__Buffered_read1_impl(self, n); exit: @@ -241,15 +241,15 @@ _io__Buffered_readinto(buffered *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__Buffered_readinto_impl(self, &buffer); exit: @@ -278,15 +278,15 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__Buffered_readinto1_impl(self, &buffer); exit: @@ -304,7 +304,7 @@ PyDoc_STRVAR(_io__Buffered_readline__doc__, "\n"); #define _IO__BUFFERED_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__}, + {"readline", (PyCFunction)(void(*)(void))_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__}, static PyObject * _io__Buffered_readline_impl(buffered *self, Py_ssize_t size); @@ -315,16 +315,16 @@ _io__Buffered_readline(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io__Buffered_readline_impl(self, size); exit: @@ -337,7 +337,7 @@ PyDoc_STRVAR(_io__Buffered_seek__doc__, "\n"); #define _IO__BUFFERED_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__}, + {"seek", (PyCFunction)(void(*)(void))_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__}, static PyObject * _io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence); @@ -349,23 +349,23 @@ _io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *targetobj; int whence = 0; - if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + goto exit; + } + targetobj = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + whence = _PyLong_AsInt(args[1]); + if (whence == -1 && PyErr_Occurred()) { goto exit; } - targetobj = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[1]); - if (whence == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io__Buffered_seek_impl(self, targetobj, whence); exit: @@ -378,7 +378,7 @@ PyDoc_STRVAR(_io__Buffered_truncate__doc__, "\n"); #define _IO__BUFFERED_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__}, static PyObject * _io__Buffered_truncate_impl(buffered *self, PyObject *pos); @@ -389,14 +389,14 @@ _io__Buffered_truncate(buffered *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - pos = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + pos = args[0]; +skip_optional: return_value = _io__Buffered_truncate_impl(self, pos); exit: @@ -418,40 +418,40 @@ _io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "BufferedReader", 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, "BufferedReader", 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 *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - 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; + } + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - raw = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(fastargs[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - buffer_size = ival; - } -skip_optional_pos: + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size); exit: @@ -477,40 +477,40 @@ _io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "BufferedWriter", 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, "BufferedWriter", 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 *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - 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; + } + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - raw = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(fastargs[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - buffer_size = ival; - } -skip_optional_pos: + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size); exit: @@ -534,13 +534,13 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io_BufferedWriter_write_impl(self, &buffer); exit: @@ -578,36 +578,36 @@ _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs) PyObject *writer; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - if (Py_IS_TYPE(self, &PyBufferedRWPair_Type) && + if (Py_IS_TYPE(self, &PyBufferedRWPair_Type) && !_PyArg_NoKeywords("BufferedRWPair", kwargs)) { goto exit; } - if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) { + if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) { + goto exit; + } + reader = PyTuple_GET_ITEM(args, 0); + writer = PyTuple_GET_ITEM(args, 1); + if (PyTuple_GET_SIZE(args) < 3) { + goto skip_optional; + } + if (PyFloat_Check(PyTuple_GET_ITEM(args, 2))) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - reader = PyTuple_GET_ITEM(args, 0); - writer = PyTuple_GET_ITEM(args, 1); - if (PyTuple_GET_SIZE(args) < 3) { - goto skip_optional; - } - if (PyFloat_Check(PyTuple_GET_ITEM(args, 2))) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 2)); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - buffer_size = ival; - } -skip_optional: + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 2)); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional: return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size); exit: @@ -633,43 +633,43 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "BufferedRandom", 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, "BufferedRandom", 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 *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - 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; } - raw = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(fastargs[1]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - buffer_size = ival; - } -skip_optional_pos: + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size); exit: return return_value; } -/*[clinic end generated code: output=7d9ad40c95bdd808 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7d9ad40c95bdd808 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/bytesio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/bytesio.c.h index a0949a6ff9..83cd490dc5 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/bytesio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/bytesio.c.h @@ -158,7 +158,7 @@ PyDoc_STRVAR(_io_BytesIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__}, static PyObject * _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size); @@ -169,16 +169,16 @@ _io_BytesIO_read(bytesio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io_BytesIO_read_impl(self, size); exit: @@ -195,7 +195,7 @@ PyDoc_STRVAR(_io_BytesIO_read1__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ1_METHODDEF \ - {"read1", (PyCFunction)(void(*)(void))_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__}, + {"read1", (PyCFunction)(void(*)(void))_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__}, static PyObject * _io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size); @@ -206,16 +206,16 @@ _io_BytesIO_read1(bytesio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io_BytesIO_read1_impl(self, size); exit: @@ -233,7 +233,7 @@ PyDoc_STRVAR(_io_BytesIO_readline__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__}, + {"readline", (PyCFunction)(void(*)(void))_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__}, static PyObject * _io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size); @@ -244,16 +244,16 @@ _io_BytesIO_readline(bytesio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io_BytesIO_readline_impl(self, size); exit: @@ -271,7 +271,7 @@ PyDoc_STRVAR(_io_BytesIO_readlines__doc__, "total number of bytes in the lines returned."); #define _IO_BYTESIO_READLINES_METHODDEF \ - {"readlines", (PyCFunction)(void(*)(void))_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__}, + {"readlines", (PyCFunction)(void(*)(void))_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__}, static PyObject * _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg); @@ -282,14 +282,14 @@ _io_BytesIO_readlines(bytesio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - arg = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + arg = args[0]; +skip_optional: return_value = _io_BytesIO_readlines_impl(self, arg); exit: @@ -317,15 +317,15 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io_BytesIO_readinto_impl(self, &buffer); exit: @@ -347,7 +347,7 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__, "The current file position is unchanged. Returns the new size."); #define _IO_BYTESIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, static PyObject * _io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size); @@ -358,16 +358,16 @@ _io_BytesIO_truncate(bytesio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = self->pos; - if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io_BytesIO_truncate_impl(self, size); exit: @@ -387,7 +387,7 @@ PyDoc_STRVAR(_io_BytesIO_seek__doc__, "Returns the new absolute position."); #define _IO_BYTESIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__}, + {"seek", (PyCFunction)(void(*)(void))_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__}, static PyObject * _io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence); @@ -399,39 +399,39 @@ _io_BytesIO_seek(bytesio *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t pos; int whence = 0; - if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("seek", 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; + } + pos = ival; + } + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); 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; - } - pos = ival; - } - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[1]); - if (whence == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + whence = _PyLong_AsInt(args[1]); + if (whence == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _io_BytesIO_seek_impl(self, pos, whence); exit: @@ -494,25 +494,25 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"initial_bytes", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "BytesIO", 0}; - PyObject *argsbuf[1]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "BytesIO", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *initvalue = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - initvalue = fastargs[0]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + initvalue = fastargs[0]; +skip_optional_pos: return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue); exit: return return_value; } -/*[clinic end generated code: output=4ec2506def9c8eb9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4ec2506def9c8eb9 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/fileio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/fileio.c.h index daf29446f7..53e7067cf7 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/fileio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/fileio.c.h @@ -50,58 +50,58 @@ _io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "FileIO", 0}; - PyObject *argsbuf[4]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "FileIO", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *nameobj; const char *mode = "r"; int closefd = 1; PyObject *opener = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); + if (!fastargs) { goto exit; } - nameobj = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[1]) { - if (!PyUnicode_Check(fastargs[1])) { - _PyArg_BadArgument("FileIO", "argument 'mode'", "str", fastargs[1]); - goto exit; - } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); - if (mode == NULL) { - goto exit; - } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[2]) { - if (PyFloat_Check(fastargs[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - closefd = _PyLong_AsInt(fastargs[2]); - if (closefd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - opener = fastargs[3]; -skip_optional_pos: + nameobj = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (!PyUnicode_Check(fastargs[1])) { + _PyArg_BadArgument("FileIO", "argument 'mode'", "str", fastargs[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(fastargs[2]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = fastargs[3]; +skip_optional_pos: return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener); exit: @@ -198,15 +198,15 @@ _io_FileIO_readinto(fileio *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io_FileIO_readinto_impl(self, &buffer); exit: @@ -250,7 +250,7 @@ PyDoc_STRVAR(_io_FileIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_FILEIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__}, static PyObject * _io_FileIO_read_impl(fileio *self, Py_ssize_t size); @@ -261,16 +261,16 @@ _io_FileIO_read(fileio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io_FileIO_read_impl(self, size); exit: @@ -299,13 +299,13 @@ _io_FileIO_write(fileio *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer b = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&b, 'C')) { + _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&b, 'C')) { - _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io_FileIO_write_impl(self, &b); exit: @@ -332,7 +332,7 @@ PyDoc_STRVAR(_io_FileIO_seek__doc__, "Note that not all file objects are seekable."); #define _IO_FILEIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__}, + {"seek", (PyCFunction)(void(*)(void))_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__}, static PyObject * _io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence); @@ -344,23 +344,23 @@ _io_FileIO_seek(fileio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *pos; int whence = 0; - if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + goto exit; + } + pos = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + whence = _PyLong_AsInt(args[1]); + if (whence == -1 && PyErr_Occurred()) { goto exit; } - pos = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[1]); - if (whence == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io_FileIO_seek_impl(self, pos, whence); exit: @@ -399,7 +399,7 @@ PyDoc_STRVAR(_io_FileIO_truncate__doc__, "The current file position is changed to the value of size."); #define _IO_FILEIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__}, static PyObject * _io_FileIO_truncate_impl(fileio *self, PyObject *posobj); @@ -408,16 +408,16 @@ static PyObject * _io_FileIO_truncate(fileio *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *posobj = Py_None; + PyObject *posobj = Py_None; - if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - posobj = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + posobj = args[0]; +skip_optional: return_value = _io_FileIO_truncate_impl(self, posobj); exit: @@ -447,4 +447,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=e7682d0a3264d284 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e7682d0a3264d284 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/iobase.c.h b/contrib/tools/python3/src/Modules/_io/clinic/iobase.c.h index 82ab4a7f27..ddaff7b5d1 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/iobase.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/iobase.c.h @@ -174,7 +174,7 @@ PyDoc_STRVAR(_io__IOBase_readline__doc__, "terminator(s) recognized."); #define _IO__IOBASE_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__}, + {"readline", (PyCFunction)(void(*)(void))_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__}, static PyObject * _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit); @@ -185,16 +185,16 @@ _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t limit = -1; - if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) { + goto exit; + } +skip_optional: return_value = _io__IOBase_readline_impl(self, limit); exit: @@ -212,7 +212,7 @@ PyDoc_STRVAR(_io__IOBase_readlines__doc__, "lines so far exceeds hint."); #define _IO__IOBASE_READLINES_METHODDEF \ - {"readlines", (PyCFunction)(void(*)(void))_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__}, + {"readlines", (PyCFunction)(void(*)(void))_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__}, static PyObject * _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint); @@ -223,16 +223,16 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t hint = -1; - if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io__IOBase_readlines_impl(self, hint); exit: @@ -242,11 +242,11 @@ exit: PyDoc_STRVAR(_io__IOBase_writelines__doc__, "writelines($self, lines, /)\n" "--\n" -"\n" -"Write a list of lines to stream.\n" -"\n" -"Line separators are not added, so it is usual for each of the\n" -"lines provided to have a line separator at the end."); +"\n" +"Write a list of lines to stream.\n" +"\n" +"Line separators are not added, so it is usual for each of the\n" +"lines provided to have a line separator at the end."); #define _IO__IOBASE_WRITELINES_METHODDEF \ {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__}, @@ -257,7 +257,7 @@ PyDoc_STRVAR(_io__RawIOBase_read__doc__, "\n"); #define _IO__RAWIOBASE_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__}, static PyObject * _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n); @@ -268,30 +268,30 @@ _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } - 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; - } - n = 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; + } + n = ival; + } +skip_optional: return_value = _io__RawIOBase_read_impl(self, n); exit: @@ -315,4 +315,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/stringio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/stringio.c.h index e1b1e6537a..77a720c2a6 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/stringio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/stringio.c.h @@ -48,7 +48,7 @@ PyDoc_STRVAR(_io_StringIO_read__doc__, "is reached. Return an empty string at EOF."); #define _IO_STRINGIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__}, static PyObject * _io_StringIO_read_impl(stringio *self, Py_ssize_t size); @@ -59,16 +59,16 @@ _io_StringIO_read(stringio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io_StringIO_read_impl(self, size); exit: @@ -84,7 +84,7 @@ PyDoc_STRVAR(_io_StringIO_readline__doc__, "Returns an empty string if EOF is hit immediately."); #define _IO_STRINGIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__}, + {"readline", (PyCFunction)(void(*)(void))_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__}, static PyObject * _io_StringIO_readline_impl(stringio *self, Py_ssize_t size); @@ -95,16 +95,16 @@ _io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: +skip_optional: return_value = _io_StringIO_readline_impl(self, size); exit: @@ -122,7 +122,7 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc__, "Returns the new absolute position."); #define _IO_STRINGIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__}, static PyObject * _io_StringIO_truncate_impl(stringio *self, Py_ssize_t size); @@ -133,16 +133,16 @@ _io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t size = self->pos; - if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io_StringIO_truncate_impl(self, size); exit: @@ -162,7 +162,7 @@ PyDoc_STRVAR(_io_StringIO_seek__doc__, "Returns the new absolute position."); #define _IO_STRINGIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__}, + {"seek", (PyCFunction)(void(*)(void))_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__}, static PyObject * _io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence); @@ -174,39 +174,39 @@ _io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs) Py_ssize_t pos; int whence = 0; - if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("seek", 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; - } - pos = ival; - } - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[1]); - if (whence == -1 && PyErr_Occurred()) { - 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; + } + pos = ival; + } + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + whence = _PyLong_AsInt(args[1]); + if (whence == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _io_StringIO_seek_impl(self, pos, whence); exit: @@ -266,29 +266,29 @@ _io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"initial_value", "newline", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "StringIO", 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, "StringIO", 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 *value = NULL; PyObject *newline_obj = 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]) { - value = fastargs[0]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - newline_obj = fastargs[1]; -skip_optional_pos: + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + value = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + newline_obj = fastargs[1]; +skip_optional_pos: return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj); exit: @@ -348,4 +348,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored)) { return _io_StringIO_seekable_impl(self); } -/*[clinic end generated code: output=7aad5ab2e64a25b8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7aad5ab2e64a25b8 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/textio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/textio.c.h index 53a8001449..b8b507543e 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/textio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/textio.c.h @@ -25,34 +25,34 @@ _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject { int return_value = -1; static const char * const _keywords[] = {"decoder", "translate", "errors", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "IncrementalNewlineDecoder", 0}; - PyObject *argsbuf[3]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; + static _PyArg_Parser _parser = {NULL, _keywords, "IncrementalNewlineDecoder", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; PyObject *decoder; int translate; PyObject *errors = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf); + if (!fastargs) { goto exit; } - decoder = fastargs[0]; - if (PyFloat_Check(fastargs[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - translate = _PyLong_AsInt(fastargs[1]); - if (translate == -1 && PyErr_Occurred()) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - errors = fastargs[2]; -skip_optional_pos: + decoder = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + translate = _PyLong_AsInt(fastargs[1]); + if (translate == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + errors = fastargs[2]; +skip_optional_pos: return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); exit: @@ -65,7 +65,7 @@ PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, "\n"); #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, + {"decode", (PyCFunction)(void(*)(void))_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, static PyObject * _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, @@ -76,30 +76,30 @@ _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *ar { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "final", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; - PyObject *argsbuf[2]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *input; int final = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + input = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[1]); + if (final == -1 && PyErr_Occurred()) { goto exit; } - input = args[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - final = _PyLong_AsInt(args[1]); - if (final == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: +skip_optional_pos: return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final); exit: @@ -193,11 +193,11 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "TextIOWrapper", 0}; - PyObject *argsbuf[6]; - 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, "TextIOWrapper", 0}; + PyObject *argsbuf[6]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *buffer; const char *encoding = NULL; PyObject *errors = Py_None; @@ -205,90 +205,90 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) int line_buffering = 0; int write_through = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf); + if (!fastargs) { goto exit; } - buffer = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[1]) { - if (fastargs[1] == Py_None) { - encoding = NULL; - } - else if (PyUnicode_Check(fastargs[1])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); - if (encoding == NULL) { - goto exit; - } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[2]) { - errors = fastargs[2]; - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[3]) { - if (fastargs[3] == Py_None) { - newline = NULL; - } - else if (PyUnicode_Check(fastargs[3])) { - Py_ssize_t newline_length; - newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); - if (newline == NULL) { - goto exit; - } - if (strlen(newline) != (size_t)newline_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[4]) { - if (PyFloat_Check(fastargs[4])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - line_buffering = _PyLong_AsInt(fastargs[4]); - if (line_buffering == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (PyFloat_Check(fastargs[5])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - write_through = _PyLong_AsInt(fastargs[5]); - if (write_through == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: + buffer = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (fastargs[1] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(fastargs[1])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + errors = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[3]) { + if (fastargs[3] == Py_None) { + newline = NULL; + } + else if (PyUnicode_Check(fastargs[3])) { + Py_ssize_t newline_length; + newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); + if (newline == NULL) { + goto exit; + } + if (strlen(newline) != (size_t)newline_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[4]) { + if (PyFloat_Check(fastargs[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + line_buffering = _PyLong_AsInt(fastargs[4]); + if (line_buffering == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(fastargs[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + write_through = _PyLong_AsInt(fastargs[5]); + if (write_through == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through); exit: @@ -305,7 +305,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__, "This also does an implicit stream flush."); #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \ - {"reconfigure", (PyCFunction)(void(*)(void))_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, + {"reconfigure", (PyCFunction)(void(*)(void))_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, static PyObject * _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, @@ -318,48 +318,48 @@ _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "reconfigure", 0}; - PyObject *argsbuf[5]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "reconfigure", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *encoding = Py_None; PyObject *errors = Py_None; PyObject *newline_obj = NULL; PyObject *line_buffering_obj = Py_None; PyObject *write_through_obj = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (args[0]) { - encoding = args[0]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[1]) { - errors = args[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[2]) { - newline_obj = args[2]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (args[3]) { - line_buffering_obj = args[3]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - write_through_obj = args[4]; -skip_optional_kwonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + encoding = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + errors = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + newline_obj = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + line_buffering_obj = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + write_through_obj = args[4]; +skip_optional_kwonly: return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); exit: @@ -400,14 +400,14 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg) PyObject *return_value = NULL; PyObject *text; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("write", "argument", "str", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("write", "argument", "str", arg); + goto exit; + } + if (PyUnicode_READY(arg) == -1) { goto exit; } - if (PyUnicode_READY(arg) == -1) { - goto exit; - } - text = arg; + text = arg; return_value = _io_TextIOWrapper_write_impl(self, text); exit: @@ -420,7 +420,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_read__doc__, "\n"); #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__}, static PyObject * _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); @@ -431,16 +431,16 @@ _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { + goto exit; + } +skip_optional: return_value = _io_TextIOWrapper_read_impl(self, n); exit: @@ -453,7 +453,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__, "\n"); #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, + {"readline", (PyCFunction)(void(*)(void))_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, static PyObject * _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); @@ -464,30 +464,30 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - { - Py_ssize_t ival = -1; - PyObject *iobj = PyNumber_Index(args[0]); - if (iobj != NULL) { - ival = PyLong_AsSsize_t(iobj); - Py_DECREF(iobj); - } - if (ival == -1 && PyErr_Occurred()) { - goto exit; - } - size = ival; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + size = ival; + } +skip_optional: return_value = _io_TextIOWrapper_readline_impl(self, size); exit: @@ -500,7 +500,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, "\n"); #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, + {"seek", (PyCFunction)(void(*)(void))_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); @@ -512,23 +512,23 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs) PyObject *cookieObj; int whence = 0; - if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { + if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { goto exit; } - cookieObj = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - whence = _PyLong_AsInt(args[1]); - if (whence == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: + cookieObj = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + whence = _PyLong_AsInt(args[1]); + if (whence == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); exit: @@ -558,7 +558,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, "\n"); #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, + {"truncate", (PyCFunction)(void(*)(void))_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, static PyObject * _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); @@ -569,14 +569,14 @@ _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - pos = args[0]; -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + pos = args[0]; +skip_optional: return_value = _io_TextIOWrapper_truncate_impl(self, pos); exit: @@ -701,4 +701,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=b1bae4f4cdf6019e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b1bae4f4cdf6019e input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/Modules/_io/clinic/winconsoleio.c.h b/contrib/tools/python3/src/Modules/_io/clinic/winconsoleio.c.h index f008678154..3e501a5853 100644 --- a/contrib/tools/python3/src/Modules/_io/clinic/winconsoleio.c.h +++ b/contrib/tools/python3/src/Modules/_io/clinic/winconsoleio.c.h @@ -49,58 +49,58 @@ _io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "_WindowsConsoleIO", 0}; - PyObject *argsbuf[4]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + static _PyArg_Parser _parser = {NULL, _keywords, "_WindowsConsoleIO", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *nameobj; const char *mode = "r"; int closefd = 1; PyObject *opener = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); - if (!fastargs) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); + if (!fastargs) { goto exit; } - nameobj = fastargs[0]; - if (!noptargs) { - goto skip_optional_pos; - } - if (fastargs[1]) { - if (!PyUnicode_Check(fastargs[1])) { - _PyArg_BadArgument("_WindowsConsoleIO", "argument 'mode'", "str", fastargs[1]); - goto exit; - } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); - if (mode == NULL) { - goto exit; - } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - if (fastargs[2]) { - if (PyFloat_Check(fastargs[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - closefd = _PyLong_AsInt(fastargs[2]); - if (closefd == -1 && PyErr_Occurred()) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_pos; - } - } - opener = fastargs[3]; -skip_optional_pos: + nameobj = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (!PyUnicode_Check(fastargs[1])) { + _PyArg_BadArgument("_WindowsConsoleIO", "argument 'mode'", "str", fastargs[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(fastargs[2]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = fastargs[3]; +skip_optional_pos: return_value = _io__WindowsConsoleIO___init___impl((winconsoleio *)self, nameobj, mode, closefd, opener); exit: @@ -198,15 +198,15 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { - PyErr_Clear(); - _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { + PyErr_Clear(); + _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&buffer, 'C')) { - _PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer); exit: @@ -257,7 +257,7 @@ PyDoc_STRVAR(_io__WindowsConsoleIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO__WINDOWSCONSOLEIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__WindowsConsoleIO_read, METH_FASTCALL, _io__WindowsConsoleIO_read__doc__}, + {"read", (PyCFunction)(void(*)(void))_io__WindowsConsoleIO_read, METH_FASTCALL, _io__WindowsConsoleIO_read__doc__}, static PyObject * _io__WindowsConsoleIO_read_impl(winconsoleio *self, Py_ssize_t size); @@ -268,16 +268,16 @@ _io__WindowsConsoleIO_read(winconsoleio *self, PyObject *const *args, Py_ssize_t PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } - if (nargs < 1) { - goto skip_optional; - } - if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { - goto exit; - } -skip_optional: + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { + goto exit; + } +skip_optional: return_value = _io__WindowsConsoleIO_read_impl(self, size); exit: @@ -309,13 +309,13 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer b = {NULL, NULL}; - if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&b, 'C')) { + _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); goto exit; } - if (!PyBuffer_IsContiguous(&b, 'C')) { - _PyArg_BadArgument("write", "argument", "contiguous buffer", arg); - goto exit; - } return_value = _io__WindowsConsoleIO_write_impl(self, &b); exit: @@ -386,4 +386,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */ -/*[clinic end generated code: output=f5b8860a658a001a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f5b8860a658a001a input=a9049054013a1b77]*/ |