1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
6 "getvalue($self, /)\n"
7 "--\n"
8 "\n"
9 "Retrieve the entire contents of the object.");
10
11 #define _IO_STRINGIO_GETVALUE_METHODDEF \
12 {"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
13
14 static PyObject *
15 _io_StringIO_getvalue_impl(stringio *self);
16
17 static PyObject *
_io_StringIO_getvalue(stringio * self,PyObject * Py_UNUSED (ignored))18 _io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
19 {
20 return _io_StringIO_getvalue_impl(self);
21 }
22
23 PyDoc_STRVAR(_io_StringIO_tell__doc__,
24 "tell($self, /)\n"
25 "--\n"
26 "\n"
27 "Tell the current file position.");
28
29 #define _IO_STRINGIO_TELL_METHODDEF \
30 {"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
31
32 static PyObject *
33 _io_StringIO_tell_impl(stringio *self);
34
35 static PyObject *
_io_StringIO_tell(stringio * self,PyObject * Py_UNUSED (ignored))36 _io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
37 {
38 return _io_StringIO_tell_impl(self);
39 }
40
41 PyDoc_STRVAR(_io_StringIO_read__doc__,
42 "read($self, size=-1, /)\n"
43 "--\n"
44 "\n"
45 "Read at most size characters, returned as a string.\n"
46 "\n"
47 "If the argument is negative or omitted, read until EOF\n"
48 "is reached. Return an empty string at EOF.");
49
50 #define _IO_STRINGIO_READ_METHODDEF \
51 {"read", (PyCFunction)_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__},
52
53 static PyObject *
54 _io_StringIO_read_impl(stringio *self, Py_ssize_t size);
55
56 static PyObject *
_io_StringIO_read(stringio * self,PyObject * const * args,Py_ssize_t nargs)57 _io_StringIO_read(stringio *self, PyObject *const *args, Py_ssize_t nargs)
58 {
59 PyObject *return_value = NULL;
60 Py_ssize_t size = -1;
61
62 if (!_PyArg_ParseStack(args, nargs, "|O&:read",
63 _Py_convert_optional_to_ssize_t, &size)) {
64 goto exit;
65 }
66 return_value = _io_StringIO_read_impl(self, size);
67
68 exit:
69 return return_value;
70 }
71
72 PyDoc_STRVAR(_io_StringIO_readline__doc__,
73 "readline($self, size=-1, /)\n"
74 "--\n"
75 "\n"
76 "Read until newline or EOF.\n"
77 "\n"
78 "Returns an empty string if EOF is hit immediately.");
79
80 #define _IO_STRINGIO_READLINE_METHODDEF \
81 {"readline", (PyCFunction)_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__},
82
83 static PyObject *
84 _io_StringIO_readline_impl(stringio *self, Py_ssize_t size);
85
86 static PyObject *
_io_StringIO_readline(stringio * self,PyObject * const * args,Py_ssize_t nargs)87 _io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
88 {
89 PyObject *return_value = NULL;
90 Py_ssize_t size = -1;
91
92 if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
93 _Py_convert_optional_to_ssize_t, &size)) {
94 goto exit;
95 }
96 return_value = _io_StringIO_readline_impl(self, size);
97
98 exit:
99 return return_value;
100 }
101
102 PyDoc_STRVAR(_io_StringIO_truncate__doc__,
103 "truncate($self, pos=None, /)\n"
104 "--\n"
105 "\n"
106 "Truncate size to pos.\n"
107 "\n"
108 "The pos argument defaults to the current file position, as\n"
109 "returned by tell(). The current file position is unchanged.\n"
110 "Returns the new absolute position.");
111
112 #define _IO_STRINGIO_TRUNCATE_METHODDEF \
113 {"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__},
114
115 static PyObject *
116 _io_StringIO_truncate_impl(stringio *self, Py_ssize_t size);
117
118 static PyObject *
_io_StringIO_truncate(stringio * self,PyObject * const * args,Py_ssize_t nargs)119 _io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
120 {
121 PyObject *return_value = NULL;
122 Py_ssize_t size = self->pos;
123
124 if (!_PyArg_ParseStack(args, nargs, "|O&:truncate",
125 _Py_convert_optional_to_ssize_t, &size)) {
126 goto exit;
127 }
128 return_value = _io_StringIO_truncate_impl(self, size);
129
130 exit:
131 return return_value;
132 }
133
134 PyDoc_STRVAR(_io_StringIO_seek__doc__,
135 "seek($self, pos, whence=0, /)\n"
136 "--\n"
137 "\n"
138 "Change stream position.\n"
139 "\n"
140 "Seek to character offset pos relative to position indicated by whence:\n"
141 " 0 Start of stream (the default). pos should be >= 0;\n"
142 " 1 Current position - pos must be 0;\n"
143 " 2 End of stream - pos must be 0.\n"
144 "Returns the new absolute position.");
145
146 #define _IO_STRINGIO_SEEK_METHODDEF \
147 {"seek", (PyCFunction)_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__},
148
149 static PyObject *
150 _io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
151
152 static PyObject *
_io_StringIO_seek(stringio * self,PyObject * const * args,Py_ssize_t nargs)153 _io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs)
154 {
155 PyObject *return_value = NULL;
156 Py_ssize_t pos;
157 int whence = 0;
158
159 if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
160 &pos, &whence)) {
161 goto exit;
162 }
163 return_value = _io_StringIO_seek_impl(self, pos, whence);
164
165 exit:
166 return return_value;
167 }
168
169 PyDoc_STRVAR(_io_StringIO_write__doc__,
170 "write($self, s, /)\n"
171 "--\n"
172 "\n"
173 "Write string to file.\n"
174 "\n"
175 "Returns the number of characters written, which is always equal to\n"
176 "the length of the string.");
177
178 #define _IO_STRINGIO_WRITE_METHODDEF \
179 {"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
180
181 PyDoc_STRVAR(_io_StringIO_close__doc__,
182 "close($self, /)\n"
183 "--\n"
184 "\n"
185 "Close the IO object.\n"
186 "\n"
187 "Attempting any further operation after the object is closed\n"
188 "will raise a ValueError.\n"
189 "\n"
190 "This method has no effect if the file is already closed.");
191
192 #define _IO_STRINGIO_CLOSE_METHODDEF \
193 {"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
194
195 static PyObject *
196 _io_StringIO_close_impl(stringio *self);
197
198 static PyObject *
_io_StringIO_close(stringio * self,PyObject * Py_UNUSED (ignored))199 _io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
200 {
201 return _io_StringIO_close_impl(self);
202 }
203
204 PyDoc_STRVAR(_io_StringIO___init____doc__,
205 "StringIO(initial_value=\'\', newline=\'\\n\')\n"
206 "--\n"
207 "\n"
208 "Text I/O implementation using an in-memory buffer.\n"
209 "\n"
210 "The initial_value argument sets the value of object. The newline\n"
211 "argument is like the one of TextIOWrapper\'s constructor.");
212
213 static int
214 _io_StringIO___init___impl(stringio *self, PyObject *value,
215 PyObject *newline_obj);
216
217 static int
_io_StringIO___init__(PyObject * self,PyObject * args,PyObject * kwargs)218 _io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
219 {
220 int return_value = -1;
221 static const char * const _keywords[] = {"initial_value", "newline", NULL};
222 static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0};
223 PyObject *value = NULL;
224 PyObject *newline_obj = NULL;
225
226 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
227 &value, &newline_obj)) {
228 goto exit;
229 }
230 return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
231
232 exit:
233 return return_value;
234 }
235
236 PyDoc_STRVAR(_io_StringIO_readable__doc__,
237 "readable($self, /)\n"
238 "--\n"
239 "\n"
240 "Returns True if the IO object can be read.");
241
242 #define _IO_STRINGIO_READABLE_METHODDEF \
243 {"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
244
245 static PyObject *
246 _io_StringIO_readable_impl(stringio *self);
247
248 static PyObject *
_io_StringIO_readable(stringio * self,PyObject * Py_UNUSED (ignored))249 _io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
250 {
251 return _io_StringIO_readable_impl(self);
252 }
253
254 PyDoc_STRVAR(_io_StringIO_writable__doc__,
255 "writable($self, /)\n"
256 "--\n"
257 "\n"
258 "Returns True if the IO object can be written.");
259
260 #define _IO_STRINGIO_WRITABLE_METHODDEF \
261 {"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
262
263 static PyObject *
264 _io_StringIO_writable_impl(stringio *self);
265
266 static PyObject *
_io_StringIO_writable(stringio * self,PyObject * Py_UNUSED (ignored))267 _io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
268 {
269 return _io_StringIO_writable_impl(self);
270 }
271
272 PyDoc_STRVAR(_io_StringIO_seekable__doc__,
273 "seekable($self, /)\n"
274 "--\n"
275 "\n"
276 "Returns True if the IO object can be seeked.");
277
278 #define _IO_STRINGIO_SEEKABLE_METHODDEF \
279 {"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
280
281 static PyObject *
282 _io_StringIO_seekable_impl(stringio *self);
283
284 static PyObject *
_io_StringIO_seekable(stringio * self,PyObject * Py_UNUSED (ignored))285 _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
286 {
287 return _io_StringIO_seekable_impl(self);
288 }
289 /*[clinic end generated code: output=73c4d6e5cc3b1a58 input=a9049054013a1b77]*/
290