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)
|
2023-08-31 18:42:34 -03:00
|
|
|
# include "pycore_gc.h" // PyGC_Head
|
|
|
|
# include "pycore_runtime.h" // _Py_ID()
|
2022-08-11 18:25:49 -03:00
|
|
|
#endif
|
2023-08-31 18:42:34 -03:00
|
|
|
#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
|
2023-11-19 08:34:40 -04:00
|
|
|
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
|
2023-10-17 09:30:31 -03:00
|
|
|
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2015-04-16 05:19:43 -03:00
|
|
|
PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
|
|
|
|
"getvalue($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Retrieve the entire contents of the object.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_GETVALUE_METHODDEF \
|
|
|
|
{"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_getvalue_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_getvalue_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_tell__doc__,
|
|
|
|
"tell($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Tell the current file position.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_TELL_METHODDEF \
|
|
|
|
{"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_tell_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_tell_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_read__doc__,
|
2017-03-10 18:52:01 -04:00
|
|
|
"read($self, size=-1, /)\n"
|
2015-04-16 05:19:43 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Read at most size characters, returned as a string.\n"
|
|
|
|
"\n"
|
|
|
|
"If the argument is negative or omitted, read until EOF\n"
|
|
|
|
"is reached. Return an empty string at EOF.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_READ_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"read", _PyCFunction_CAST(_io_StringIO_read), METH_FASTCALL, _io_StringIO_read__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-03-10 18:52:01 -04:00
|
|
|
_io_StringIO_read_impl(stringio *self, Py_ssize_t size);
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_StringIO_read(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2017-03-10 18:52:01 -04:00
|
|
|
Py_ssize_t size = -1;
|
2015-04-16 05:19:43 -03:00
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
2017-01-16 21:21:47 -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], &size)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional:
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
2017-03-10 18:52:01 -04:00
|
|
|
return_value = _io_StringIO_read_impl(self, size);
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_END_CRITICAL_SECTION();
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_readline__doc__,
|
2017-03-10 18:52:01 -04:00
|
|
|
"readline($self, size=-1, /)\n"
|
2015-04-16 05:19:43 -03:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Read until newline or EOF.\n"
|
|
|
|
"\n"
|
|
|
|
"Returns an empty string if EOF is hit immediately.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_READLINE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"readline", _PyCFunction_CAST(_io_StringIO_readline), METH_FASTCALL, _io_StringIO_readline__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-03-10 18:52:01 -04:00
|
|
|
_io_StringIO_readline_impl(stringio *self, Py_ssize_t size);
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2017-03-10 18:52:01 -04:00
|
|
|
Py_ssize_t size = -1;
|
2015-04-16 05:19:43 -03:00
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
2017-01-16 21:21:47 -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], &size)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional:
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
2017-03-10 18:52:01 -04:00
|
|
|
return_value = _io_StringIO_readline_impl(self, size);
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_END_CRITICAL_SECTION();
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_truncate__doc__,
|
|
|
|
"truncate($self, pos=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Truncate size to pos.\n"
|
|
|
|
"\n"
|
|
|
|
"The pos argument defaults to the current file position, as\n"
|
|
|
|
"returned by tell(). The current file position is unchanged.\n"
|
|
|
|
"Returns the new absolute position.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_TRUNCATE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"truncate", _PyCFunction_CAST(_io_StringIO_truncate), METH_FASTCALL, _io_StringIO_truncate__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-03-30 03:15:31 -03:00
|
|
|
_io_StringIO_truncate_impl(stringio *self, Py_ssize_t size);
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2017-03-30 03:15:31 -03:00
|
|
|
Py_ssize_t size = self->pos;
|
2015-04-16 05:19:43 -03:00
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
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)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
skip_optional:
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
2017-03-30 03:15:31 -03:00
|
|
|
return_value = _io_StringIO_truncate_impl(self, size);
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_END_CRITICAL_SECTION();
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_seek__doc__,
|
|
|
|
"seek($self, pos, whence=0, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Change stream position.\n"
|
|
|
|
"\n"
|
|
|
|
"Seek to character offset pos relative to position indicated by whence:\n"
|
|
|
|
" 0 Start of stream (the default). pos should be >= 0;\n"
|
|
|
|
" 1 Current position - pos must be 0;\n"
|
|
|
|
" 2 End of stream - pos must be 0.\n"
|
|
|
|
"Returns the new absolute position.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_SEEK_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"seek", _PyCFunction_CAST(_io_StringIO_seek), METH_FASTCALL, _io_StringIO_seek__doc__},
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-16 05:19:43 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
Py_ssize_t pos;
|
|
|
|
int whence = 0;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
pos = ival;
|
|
|
|
}
|
|
|
|
if (nargs < 2) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
2023-08-24 19:51:22 -03:00
|
|
|
whence = PyLong_AsInt(args[1]);
|
2019-01-11 10:01:14 -04:00
|
|
|
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:
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_StringIO_seek_impl(self, pos, whence);
|
2023-11-19 08:34:40 -04:00
|
|
|
Py_END_CRITICAL_SECTION();
|
2015-04-16 05:19:43 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_write__doc__,
|
|
|
|
"write($self, s, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Write string to file.\n"
|
|
|
|
"\n"
|
|
|
|
"Returns the number of characters written, which is always equal to\n"
|
|
|
|
"the length of the string.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_WRITE_METHODDEF \
|
|
|
|
{"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
|
|
|
|
|
2023-11-19 08:34:40 -04:00
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_write_impl(stringio *self, PyObject *obj);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_write(stringio *self, PyObject *obj)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_write_impl(self, obj);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2015-04-16 05:19:43 -03:00
|
|
|
PyDoc_STRVAR(_io_StringIO_close__doc__,
|
|
|
|
"close($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Close the IO object.\n"
|
|
|
|
"\n"
|
|
|
|
"Attempting any further operation after the object is closed\n"
|
|
|
|
"will raise a ValueError.\n"
|
|
|
|
"\n"
|
|
|
|
"This method has no effect if the file is already closed.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_CLOSE_METHODDEF \
|
|
|
|
{"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_close_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_close_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO___init____doc__,
|
|
|
|
"StringIO(initial_value=\'\', newline=\'\\n\')\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Text I/O implementation using an in-memory buffer.\n"
|
|
|
|
"\n"
|
|
|
|
"The initial_value argument sets the value of object. The newline\n"
|
|
|
|
"argument is like the one of TextIOWrapper\'s constructor.");
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_StringIO___init___impl(stringio *self, PyObject *value,
|
|
|
|
PyObject *newline_obj);
|
|
|
|
|
|
|
|
static int
|
|
|
|
_io_StringIO___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 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(initial_value), &_Py_ID(newline), },
|
|
|
|
};
|
|
|
|
#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[] = {"initial_value", "newline", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "StringIO",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
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;
|
2015-04-16 05:19:43 -03:00
|
|
|
PyObject *value = NULL;
|
|
|
|
PyObject *newline_obj = NULL;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 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
|
|
|
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:
|
2015-04-16 05:19:43 -03:00
|
|
|
return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_readable__doc__,
|
|
|
|
"readable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Returns True if the IO object can be read.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_READABLE_METHODDEF \
|
|
|
|
{"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_readable_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_readable_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_writable__doc__,
|
|
|
|
"writable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Returns True if the IO object can be written.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_WRITABLE_METHODDEF \
|
|
|
|
{"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_writable_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_writable_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO_seekable__doc__,
|
|
|
|
"seekable($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Returns True if the IO object can be seeked.");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO_SEEKABLE_METHODDEF \
|
|
|
|
{"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_seekable_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
2023-11-19 08:34:40 -04:00
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_seekable_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO___getstate____doc__,
|
|
|
|
"__getstate__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO___GETSTATE___METHODDEF \
|
|
|
|
{"__getstate__", (PyCFunction)_io_StringIO___getstate__, METH_NOARGS, _io_StringIO___getstate____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO___getstate___impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO___getstate__(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO___getstate___impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_io_StringIO___setstate____doc__,
|
|
|
|
"__setstate__($self, state, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _IO_STRINGIO___SETSTATE___METHODDEF \
|
|
|
|
{"__setstate__", (PyCFunction)_io_StringIO___setstate__, METH_O, _io_StringIO___setstate____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO___setstate___impl(stringio *self, PyObject *state);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO___setstate__(stringio *self, PyObject *state)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO___setstate___impl(self, state);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
2015-04-16 05:19:43 -03:00
|
|
|
}
|
2023-11-30 19:37:30 -04:00
|
|
|
|
2023-12-20 08:52:12 -04:00
|
|
|
#if defined(_io_StringIO_closed_HAS_DOCSTR)
|
|
|
|
# define _io_StringIO_closed_DOCSTR _io_StringIO_closed__doc__
|
|
|
|
#else
|
|
|
|
# define _io_StringIO_closed_DOCSTR NULL
|
|
|
|
#endif
|
2023-12-13 10:00:34 -04:00
|
|
|
#if defined(_IO_STRINGIO_CLOSED_GETSETDEF)
|
|
|
|
# undef _IO_STRINGIO_CLOSED_GETSETDEF
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_CLOSED_GETSETDEF {"closed", (getter)_io_StringIO_closed_get, (setter)_io_StringIO_closed_set, _io_StringIO_closed_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#else
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_CLOSED_GETSETDEF {"closed", (getter)_io_StringIO_closed_get, NULL, _io_StringIO_closed_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#endif
|
2023-11-30 19:37:30 -04:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_closed_get_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_closed_get(stringio *self, void *Py_UNUSED(context))
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_closed_get_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2023-12-20 08:52:12 -04:00
|
|
|
#if defined(_io_StringIO_line_buffering_HAS_DOCSTR)
|
|
|
|
# define _io_StringIO_line_buffering_DOCSTR _io_StringIO_line_buffering__doc__
|
|
|
|
#else
|
|
|
|
# define _io_StringIO_line_buffering_DOCSTR NULL
|
|
|
|
#endif
|
2023-12-13 10:00:34 -04:00
|
|
|
#if defined(_IO_STRINGIO_LINE_BUFFERING_GETSETDEF)
|
|
|
|
# undef _IO_STRINGIO_LINE_BUFFERING_GETSETDEF
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_LINE_BUFFERING_GETSETDEF {"line_buffering", (getter)_io_StringIO_line_buffering_get, (setter)_io_StringIO_line_buffering_set, _io_StringIO_line_buffering_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#else
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_LINE_BUFFERING_GETSETDEF {"line_buffering", (getter)_io_StringIO_line_buffering_get, NULL, _io_StringIO_line_buffering_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#endif
|
2023-11-30 19:37:30 -04:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_line_buffering_get_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_line_buffering_get(stringio *self, void *Py_UNUSED(context))
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_line_buffering_get_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2023-12-20 08:52:12 -04:00
|
|
|
#if defined(_io_StringIO_newlines_HAS_DOCSTR)
|
|
|
|
# define _io_StringIO_newlines_DOCSTR _io_StringIO_newlines__doc__
|
|
|
|
#else
|
|
|
|
# define _io_StringIO_newlines_DOCSTR NULL
|
|
|
|
#endif
|
2023-12-13 10:00:34 -04:00
|
|
|
#if defined(_IO_STRINGIO_NEWLINES_GETSETDEF)
|
|
|
|
# undef _IO_STRINGIO_NEWLINES_GETSETDEF
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_NEWLINES_GETSETDEF {"newlines", (getter)_io_StringIO_newlines_get, (setter)_io_StringIO_newlines_set, _io_StringIO_newlines_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#else
|
2023-12-20 08:52:12 -04:00
|
|
|
# define _IO_STRINGIO_NEWLINES_GETSETDEF {"newlines", (getter)_io_StringIO_newlines_get, NULL, _io_StringIO_newlines_DOCSTR},
|
2023-12-13 10:00:34 -04:00
|
|
|
#endif
|
2023-11-30 19:37:30 -04:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_newlines_get_impl(stringio *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_io_StringIO_newlines_get(stringio *self, void *Py_UNUSED(context))
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_CRITICAL_SECTION(self);
|
|
|
|
return_value = _io_StringIO_newlines_get_impl(self);
|
|
|
|
Py_END_CRITICAL_SECTION();
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
2023-12-20 08:52:12 -04:00
|
|
|
/*[clinic end generated code: output=9ffea20cd32d4cd8 input=a9049054013a1b77]*/
|