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