2015-04-16 05:19:43 -03:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2022-08-11 18:25:49 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# include "pycore_gc.h" // PyGC_Head
|
|
|
|
# include "pycore_runtime.h" // _Py_ID()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2023-05-11 07:19:22 -03:00
|
|
|
PyDoc_STRVAR(_io__TextIOBase_detach__doc__,
|
|
|
|
"detach($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Separate the underlying buffer from the TextIOBase and return it.\n"
|
|
|
|
"\n"
|
|
|
|
"After the underlying buffer has been detached, the TextIO is in an unusable state.");
|
|
|
|
|
|
|
|
#define _IO__TEXTIOBASE_DETACH_METHODDEF \
|
|
|
|
{"detach", _PyCFunction_CAST(_io__TextIOBase_detach), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_detach__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_detach_impl(PyObject *self, PyTypeObject *cls);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_detach(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
if (nargs) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "detach() takes no arguments");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return _io__TextIOBase_detach_impl(self, cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io__TextIOBase_read__doc__,
|
2023-05-15 08:21:38 -03:00
|
|
|
"read($self, size=-1, /)\n"
|
2023-05-11 07:19:22 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Read at most size characters from stream.\n"
|
|
|
|
"\n"
|
|
|
|
"Read from underlying buffer until we have size characters or we hit EOF.\n"
|
|
|
|
"If size is negative or omitted, read until EOF.");
|
|
|
|
|
|
|
|
#define _IO__TEXTIOBASE_READ_METHODDEF \
|
|
|
|
{"read", _PyCFunction_CAST(_io__TextIOBase_read), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_read__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
2023-05-15 08:21:38 -03:00
|
|
|
_io__TextIOBase_read_impl(PyObject *self, PyTypeObject *cls,
|
|
|
|
int Py_UNUSED(size));
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
static const char * const _keywords[] = {"", NULL};
|
2023-05-11 07:19:22 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "read",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
2023-05-15 08:21:38 -03:00
|
|
|
int size = -1;
|
2023-05-11 07:19:22 -03:00
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
|
2023-05-11 07:19:22 -03:00
|
|
|
if (!args) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2023-05-15 08:21:38 -03:00
|
|
|
if (nargs < 1) {
|
|
|
|
goto skip_optional_posonly;
|
|
|
|
}
|
|
|
|
size = _PyLong_AsInt(args[0]);
|
|
|
|
if (size == -1 && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional_posonly:
|
|
|
|
return_value = _io__TextIOBase_read_impl(self, cls, size);
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io__TextIOBase_readline__doc__,
|
2023-05-15 08:21:38 -03:00
|
|
|
"readline($self, size=-1, /)\n"
|
2023-05-11 07:19:22 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Read until newline or EOF.\n"
|
|
|
|
"\n"
|
2023-05-15 08:21:38 -03:00
|
|
|
"Return an empty string if EOF is hit immediately.\n"
|
|
|
|
"If size is specified, at most size characters will be read.");
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
#define _IO__TEXTIOBASE_READLINE_METHODDEF \
|
|
|
|
{"readline", _PyCFunction_CAST(_io__TextIOBase_readline), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_readline__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_readline_impl(PyObject *self, PyTypeObject *cls,
|
2023-05-15 08:21:38 -03:00
|
|
|
int Py_UNUSED(size));
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_readline(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
static const char * const _keywords[] = {"", NULL};
|
2023-05-11 07:19:22 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "readline",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
2023-05-15 08:21:38 -03:00
|
|
|
int size = -1;
|
2023-05-11 07:19:22 -03:00
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
|
2023-05-11 07:19:22 -03:00
|
|
|
if (!args) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2023-05-15 08:21:38 -03:00
|
|
|
if (nargs < 1) {
|
|
|
|
goto skip_optional_posonly;
|
|
|
|
}
|
|
|
|
size = _PyLong_AsInt(args[0]);
|
|
|
|
if (size == -1 && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional_posonly:
|
|
|
|
return_value = _io__TextIOBase_readline_impl(self, cls, size);
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io__TextIOBase_write__doc__,
|
2023-05-15 08:21:38 -03:00
|
|
|
"write($self, s, /)\n"
|
2023-05-11 07:19:22 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
2023-05-15 08:21:38 -03:00
|
|
|
"Write string s to stream.\n"
|
2023-05-11 07:19:22 -03:00
|
|
|
"\n"
|
|
|
|
"Return the number of characters written\n"
|
|
|
|
"(which is always equal to the length of the string).");
|
|
|
|
|
|
|
|
#define _IO__TEXTIOBASE_WRITE_METHODDEF \
|
|
|
|
{"write", _PyCFunction_CAST(_io__TextIOBase_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_write__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
2023-05-15 08:21:38 -03:00
|
|
|
_io__TextIOBase_write_impl(PyObject *self, PyTypeObject *cls,
|
|
|
|
const char *Py_UNUSED(s));
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io__TextIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
static const char * const _keywords[] = {"", NULL};
|
2023-05-11 07:19:22 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "write",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
2023-05-15 08:21:38 -03:00
|
|
|
const char *s;
|
2023-05-11 07:19:22 -03:00
|
|
|
|
2023-05-15 08:21:38 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
2023-05-11 07:19:22 -03:00
|
|
|
if (!args) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2023-05-15 08:21:38 -03:00
|
|
|
if (!PyUnicode_Check(args[0])) {
|
|
|
|
_PyArg_BadArgument("write", "argument 1", "str", args[0]);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
Py_ssize_t s_length;
|
|
|
|
s = PyUnicode_AsUTF8AndSize(args[0], &s_length);
|
|
|
|
if (s == NULL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (strlen(s) != (size_t)s_length) {
|
|
|
|
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
return_value = _io__TextIOBase_write_impl(self, cls, s);
|
2023-05-11 07:19:22 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2015-04-16 05:19:43 -03:00
|
|
|
PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__,
|
|
|
|
"IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Codec used when reading a file in universal newlines mode.\n"
|
|
|
|
"\n"
|
|
|
|
"It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n"
|
|
|
|
"It also records the types of newlines encountered. When used with\n"
|
|
|
|
"translate=False, it ensures that the newline sequence is returned in\n"
|
|
|
|
"one piece. When used with decoder=None, it expects unicode strings as\n"
|
|
|
|
"decode input and translates newlines without first invoking an external\n"
|
|
|
|
"decoder.");
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
|
|
|
|
PyObject *decoder, int translate,
|
|
|
|
PyObject *errors);
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
int return_value = -1;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 3
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(decoder), &_Py_ID(translate), &_Py_ID(errors), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "IncrementalNewlineDecoder",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
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;
|
2015-04-16 05:19:43 -03:00
|
|
|
PyObject *decoder;
|
|
|
|
int translate;
|
|
|
|
PyObject *errors = NULL;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf);
|
|
|
|
if (!fastargs) {
|
2015-04-16 05:19:43 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
decoder = fastargs[0];
|
2022-12-03 15:52:21 -04:00
|
|
|
translate = PyObject_IsTrue(fastargs[1]);
|
|
|
|
if (translate < 0) {
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
errors = fastargs[2];
|
|
|
|
skip_optional_pos:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
|
|
|
|
"decode($self, /, input, final=False)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"decode", _PyCFunction_CAST(_io_IncrementalNewlineDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
|
|
|
|
PyObject *input, int final);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(input), &_Py_ID(final), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"input", "final", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "decode",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-04-16 05:19:43 -03:00
|
|
|
PyObject *input;
|
|
|
|
int final = 0;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
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;
|
|
|
|
}
|
2022-12-03 15:52:21 -04:00
|
|
|
final = PyObject_IsTrue(args[1]);
|
|
|
|
if (final < 0) {
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional_pos:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__,
|
|
|
|
"getstate($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \
|
|
|
|
{"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_IncrementalNewlineDecoder_getstate_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__,
|
|
|
|
"setstate($self, state, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \
|
|
|
|
{"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__},
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__,
|
|
|
|
"reset($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \
|
|
|
|
{"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_IncrementalNewlineDecoder_reset_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper___init____doc__,
|
|
|
|
"TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n"
|
|
|
|
" line_buffering=False, write_through=False)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Character and line based layer over a BufferedIOBase object, buffer.\n"
|
|
|
|
"\n"
|
|
|
|
"encoding gives the name of the encoding that the stream will be\n"
|
2022-04-14 04:00:35 -03:00
|
|
|
"decoded or encoded with. It defaults to locale.getencoding().\n"
|
2015-04-16 05:19:43 -03:00
|
|
|
"\n"
|
|
|
|
"errors determines the strictness of encoding and decoding (see\n"
|
|
|
|
"help(codecs.Codec) or the documentation for codecs.register) and\n"
|
|
|
|
"defaults to \"strict\".\n"
|
|
|
|
"\n"
|
|
|
|
"newline controls how line endings are handled. It can be None, \'\',\n"
|
|
|
|
"\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n"
|
|
|
|
"\n"
|
|
|
|
"* On input, if newline is None, universal newlines mode is\n"
|
|
|
|
" enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
|
|
|
|
" these are translated into \'\\n\' before being returned to the\n"
|
|
|
|
" caller. If it is \'\', universal newline mode is enabled, but line\n"
|
|
|
|
" endings are returned to the caller untranslated. If it has any of\n"
|
|
|
|
" the other legal values, input lines are only terminated by the given\n"
|
|
|
|
" string, and the line ending is returned to the caller untranslated.\n"
|
|
|
|
"\n"
|
|
|
|
"* On output, if newline is None, any \'\\n\' characters written are\n"
|
|
|
|
" translated to the system default line separator, os.linesep. If\n"
|
|
|
|
" newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
|
|
|
|
" of the other legal values, any \'\\n\' characters written are translated\n"
|
|
|
|
" to the given string.\n"
|
|
|
|
"\n"
|
|
|
|
"If line_buffering is True, a call to flush is implied when a call to\n"
|
|
|
|
"write contains a newline character.");
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
|
2017-12-20 20:59:53 -04:00
|
|
|
const char *encoding, PyObject *errors,
|
2015-04-16 05:19:43 -03:00
|
|
|
const char *newline, int line_buffering,
|
|
|
|
int write_through);
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
int return_value = -1;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 6
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(buffer), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "TextIOWrapper",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
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;
|
2015-04-16 05:19:43 -03:00
|
|
|
PyObject *buffer;
|
|
|
|
const char *encoding = NULL;
|
2017-12-20 20:59:53 -04:00
|
|
|
PyObject *errors = Py_None;
|
2015-04-16 05:19:43 -03:00
|
|
|
const char *newline = NULL;
|
|
|
|
int line_buffering = 0;
|
|
|
|
int write_through = 0;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf);
|
|
|
|
if (!fastargs) {
|
2015-04-16 05:19:43 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
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 {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]);
|
2019-03-14 05:32:22 -03:00
|
|
|
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 {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]);
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fastargs[4]) {
|
2022-12-03 15:52:21 -04:00
|
|
|
line_buffering = PyObject_IsTrue(fastargs[4]);
|
|
|
|
if (line_buffering < 0) {
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
}
|
2022-12-03 15:52:21 -04:00
|
|
|
write_through = PyObject_IsTrue(fastargs[5]);
|
|
|
|
if (write_through < 0) {
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional_pos:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2017-06-03 07:32:28 -03:00
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__,
|
2017-12-20 20:59:53 -04:00
|
|
|
"reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n"
|
|
|
|
" line_buffering=None, write_through=None)\n"
|
2017-06-03 07:32:28 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Reconfigure the text stream with new parameters.\n"
|
|
|
|
"\n"
|
|
|
|
"This also does an implicit stream flush.");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"reconfigure", _PyCFunction_CAST(_io_TextIOWrapper_reconfigure), METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__},
|
2017-06-03 07:32:28 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-20 20:59:53 -04:00
|
|
|
_io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
|
|
|
|
PyObject *errors, PyObject *newline_obj,
|
2017-06-03 07:32:28 -03:00
|
|
|
PyObject *line_buffering_obj,
|
|
|
|
PyObject *write_through_obj);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2017-06-03 07:32:28 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 5
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2017-12-20 20:59:53 -04:00
|
|
|
static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "reconfigure",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[5];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
|
2017-12-20 20:59:53 -04:00
|
|
|
PyObject *encoding = Py_None;
|
|
|
|
PyObject *errors = Py_None;
|
|
|
|
PyObject *newline_obj = NULL;
|
2017-06-03 07:32:28 -03:00
|
|
|
PyObject *line_buffering_obj = Py_None;
|
|
|
|
PyObject *write_through_obj = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
|
|
|
|
if (!args) {
|
2017-06-03 07:32:28 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
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:
|
2017-12-20 20:59:53 -04:00
|
|
|
return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj);
|
2017-06-03 07:32:28 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2015-04-16 05:19:43 -03:00
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__,
|
|
|
|
"detach($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \
|
|
|
|
{"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_detach_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_detach_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_write__doc__,
|
|
|
|
"write($self, text, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \
|
|
|
|
{"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_write_impl(textio *self, PyObject *text);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_write(textio *self, PyObject *arg)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *text;
|
|
|
|
|
2018-12-25 07:23:47 -04:00
|
|
|
if (!PyUnicode_Check(arg)) {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("write", "argument", "str", arg);
|
2015-04-16 05:19:43 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2018-12-25 07:23:47 -04:00
|
|
|
text = arg;
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper_write_impl(self, text);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_read__doc__,
|
|
|
|
"read($self, size=-1, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_READ_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"read", _PyCFunction_CAST(_io_TextIOWrapper_read), METH_FASTCALL, _io_TextIOWrapper_read__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
Py_ssize_t n = -1;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
2017-01-16 20:35:17 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
if (nargs < 1) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper_read_impl(self, n);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
|
|
|
|
"readline($self, size=-1, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"readline", _PyCFunction_CAST(_io_TextIOWrapper_readline), METH_FASTCALL, _io_TextIOWrapper_readline__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
Py_ssize_t size = -1;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (nargs < 1) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Py_ssize_t ival = -1;
|
2020-05-28 04:33:45 -03:00
|
|
|
PyObject *iobj = _PyNumber_Index(args[0]);
|
2019-01-11 10:01:14 -04:00
|
|
|
if (iobj != NULL) {
|
|
|
|
ival = PyLong_AsSsize_t(iobj);
|
|
|
|
Py_DECREF(iobj);
|
|
|
|
}
|
|
|
|
if (ival == -1 && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
size = ival;
|
|
|
|
}
|
|
|
|
skip_optional:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper_readline_impl(self, size);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
|
|
|
|
"seek($self, cookie, whence=0, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"seek", _PyCFunction_CAST(_io_TextIOWrapper_seek), METH_FASTCALL, _io_TextIOWrapper_seek__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *cookieObj;
|
|
|
|
int whence = 0;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cookieObj = args[0];
|
|
|
|
if (nargs < 2) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
whence = _PyLong_AsInt(args[1]);
|
|
|
|
if (whence == -1 && PyErr_Occurred()) {
|
2017-01-16 20:35:17 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
skip_optional:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
|
|
|
|
"tell($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_TELL_METHODDEF \
|
|
|
|
{"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_tell_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_tell_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
|
|
|
|
"truncate($self, pos=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"truncate", _PyCFunction_CAST(_io_TextIOWrapper_truncate), METH_FASTCALL, _io_TextIOWrapper_truncate__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *pos = Py_None;
|
|
|
|
|
2019-01-11 12:01:42 -04:00
|
|
|
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
if (nargs < 1) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
pos = args[0];
|
|
|
|
skip_optional:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_TextIOWrapper_truncate_impl(self, pos);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__,
|
|
|
|
"fileno($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \
|
|
|
|
{"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_fileno_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_fileno_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__,
|
|
|
|
"seekable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \
|
|
|
|
{"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_seekable_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_seekable_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__,
|
|
|
|
"readable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \
|
|
|
|
{"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_readable_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_readable_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__,
|
|
|
|
"writable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \
|
|
|
|
{"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_writable_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_writable_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__,
|
|
|
|
"isatty($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \
|
|
|
|
{"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_isatty_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_isatty_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__,
|
|
|
|
"flush($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \
|
|
|
|
{"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_flush_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_flush_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_TextIOWrapper_close__doc__,
|
|
|
|
"close($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \
|
|
|
|
{"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_close_impl(textio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _io_TextIOWrapper_close_impl(self);
|
|
|
|
}
|
2023-06-01 20:31:58 -03:00
|
|
|
/*[clinic end generated code: output=e1060638b65e8a63 input=a9049054013a1b77]*/
|