Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(_io_BytesIO_readable__doc__, |
| 6 | "readable($self, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "Returns True if the IO object can be read."); |
| 10 | |
| 11 | #define _IO_BYTESIO_READABLE_METHODDEF \ |
| 12 | {"readable", (PyCFunction)_io_BytesIO_readable, METH_NOARGS, _io_BytesIO_readable__doc__}, |
| 13 | |
| 14 | static PyObject * |
| 15 | _io_BytesIO_readable_impl(bytesio *self); |
| 16 | |
| 17 | static PyObject * |
| 18 | _io_BytesIO_readable(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 19 | { |
| 20 | return _io_BytesIO_readable_impl(self); |
| 21 | } |
| 22 | |
| 23 | PyDoc_STRVAR(_io_BytesIO_writable__doc__, |
| 24 | "writable($self, /)\n" |
| 25 | "--\n" |
| 26 | "\n" |
| 27 | "Returns True if the IO object can be written."); |
| 28 | |
| 29 | #define _IO_BYTESIO_WRITABLE_METHODDEF \ |
| 30 | {"writable", (PyCFunction)_io_BytesIO_writable, METH_NOARGS, _io_BytesIO_writable__doc__}, |
| 31 | |
| 32 | static PyObject * |
| 33 | _io_BytesIO_writable_impl(bytesio *self); |
| 34 | |
| 35 | static PyObject * |
| 36 | _io_BytesIO_writable(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 37 | { |
| 38 | return _io_BytesIO_writable_impl(self); |
| 39 | } |
| 40 | |
| 41 | PyDoc_STRVAR(_io_BytesIO_seekable__doc__, |
| 42 | "seekable($self, /)\n" |
| 43 | "--\n" |
| 44 | "\n" |
| 45 | "Returns True if the IO object can be seeked."); |
| 46 | |
| 47 | #define _IO_BYTESIO_SEEKABLE_METHODDEF \ |
| 48 | {"seekable", (PyCFunction)_io_BytesIO_seekable, METH_NOARGS, _io_BytesIO_seekable__doc__}, |
| 49 | |
| 50 | static PyObject * |
| 51 | _io_BytesIO_seekable_impl(bytesio *self); |
| 52 | |
| 53 | static PyObject * |
| 54 | _io_BytesIO_seekable(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 55 | { |
| 56 | return _io_BytesIO_seekable_impl(self); |
| 57 | } |
| 58 | |
| 59 | PyDoc_STRVAR(_io_BytesIO_flush__doc__, |
| 60 | "flush($self, /)\n" |
| 61 | "--\n" |
| 62 | "\n" |
| 63 | "Does nothing."); |
| 64 | |
| 65 | #define _IO_BYTESIO_FLUSH_METHODDEF \ |
| 66 | {"flush", (PyCFunction)_io_BytesIO_flush, METH_NOARGS, _io_BytesIO_flush__doc__}, |
| 67 | |
| 68 | static PyObject * |
| 69 | _io_BytesIO_flush_impl(bytesio *self); |
| 70 | |
| 71 | static PyObject * |
| 72 | _io_BytesIO_flush(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 73 | { |
| 74 | return _io_BytesIO_flush_impl(self); |
| 75 | } |
| 76 | |
| 77 | PyDoc_STRVAR(_io_BytesIO_getbuffer__doc__, |
| 78 | "getbuffer($self, /)\n" |
| 79 | "--\n" |
| 80 | "\n" |
| 81 | "Get a read-write view over the contents of the BytesIO object."); |
| 82 | |
| 83 | #define _IO_BYTESIO_GETBUFFER_METHODDEF \ |
| 84 | {"getbuffer", (PyCFunction)_io_BytesIO_getbuffer, METH_NOARGS, _io_BytesIO_getbuffer__doc__}, |
| 85 | |
| 86 | static PyObject * |
| 87 | _io_BytesIO_getbuffer_impl(bytesio *self); |
| 88 | |
| 89 | static PyObject * |
| 90 | _io_BytesIO_getbuffer(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 91 | { |
| 92 | return _io_BytesIO_getbuffer_impl(self); |
| 93 | } |
| 94 | |
| 95 | PyDoc_STRVAR(_io_BytesIO_getvalue__doc__, |
| 96 | "getvalue($self, /)\n" |
| 97 | "--\n" |
| 98 | "\n" |
| 99 | "Retrieve the entire contents of the BytesIO object."); |
| 100 | |
| 101 | #define _IO_BYTESIO_GETVALUE_METHODDEF \ |
| 102 | {"getvalue", (PyCFunction)_io_BytesIO_getvalue, METH_NOARGS, _io_BytesIO_getvalue__doc__}, |
| 103 | |
| 104 | static PyObject * |
| 105 | _io_BytesIO_getvalue_impl(bytesio *self); |
| 106 | |
| 107 | static PyObject * |
| 108 | _io_BytesIO_getvalue(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 109 | { |
| 110 | return _io_BytesIO_getvalue_impl(self); |
| 111 | } |
| 112 | |
| 113 | PyDoc_STRVAR(_io_BytesIO_isatty__doc__, |
| 114 | "isatty($self, /)\n" |
| 115 | "--\n" |
| 116 | "\n" |
| 117 | "Always returns False.\n" |
| 118 | "\n" |
| 119 | "BytesIO objects are not connected to a TTY-like device."); |
| 120 | |
| 121 | #define _IO_BYTESIO_ISATTY_METHODDEF \ |
| 122 | {"isatty", (PyCFunction)_io_BytesIO_isatty, METH_NOARGS, _io_BytesIO_isatty__doc__}, |
| 123 | |
| 124 | static PyObject * |
| 125 | _io_BytesIO_isatty_impl(bytesio *self); |
| 126 | |
| 127 | static PyObject * |
| 128 | _io_BytesIO_isatty(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 129 | { |
| 130 | return _io_BytesIO_isatty_impl(self); |
| 131 | } |
| 132 | |
| 133 | PyDoc_STRVAR(_io_BytesIO_tell__doc__, |
| 134 | "tell($self, /)\n" |
| 135 | "--\n" |
| 136 | "\n" |
| 137 | "Current file position, an integer."); |
| 138 | |
| 139 | #define _IO_BYTESIO_TELL_METHODDEF \ |
| 140 | {"tell", (PyCFunction)_io_BytesIO_tell, METH_NOARGS, _io_BytesIO_tell__doc__}, |
| 141 | |
| 142 | static PyObject * |
| 143 | _io_BytesIO_tell_impl(bytesio *self); |
| 144 | |
| 145 | static PyObject * |
| 146 | _io_BytesIO_tell(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 147 | { |
| 148 | return _io_BytesIO_tell_impl(self); |
| 149 | } |
| 150 | |
| 151 | PyDoc_STRVAR(_io_BytesIO_read__doc__, |
| 152 | "read($self, size=None, /)\n" |
| 153 | "--\n" |
| 154 | "\n" |
| 155 | "Read at most size bytes, returned as a bytes object.\n" |
| 156 | "\n" |
| 157 | "If the size argument is negative, read until EOF is reached.\n" |
| 158 | "Return an empty bytes object at EOF."); |
| 159 | |
| 160 | #define _IO_BYTESIO_READ_METHODDEF \ |
| 161 | {"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__}, |
| 162 | |
| 163 | static PyObject * |
| 164 | _io_BytesIO_read_impl(bytesio *self, PyObject *arg); |
| 165 | |
| 166 | static PyObject * |
| 167 | _io_BytesIO_read(bytesio *self, PyObject *args) |
| 168 | { |
| 169 | PyObject *return_value = NULL; |
| 170 | PyObject *arg = Py_None; |
| 171 | |
| 172 | if (!PyArg_UnpackTuple(args, "read", |
| 173 | 0, 1, |
| 174 | &arg)) |
| 175 | goto exit; |
| 176 | return_value = _io_BytesIO_read_impl(self, arg); |
| 177 | |
| 178 | exit: |
| 179 | return return_value; |
| 180 | } |
| 181 | |
| 182 | PyDoc_STRVAR(_io_BytesIO_read1__doc__, |
| 183 | "read1($self, size, /)\n" |
| 184 | "--\n" |
| 185 | "\n" |
| 186 | "Read at most size bytes, returned as a bytes object.\n" |
| 187 | "\n" |
| 188 | "If the size argument is negative or omitted, read until EOF is reached.\n" |
| 189 | "Return an empty bytes object at EOF."); |
| 190 | |
| 191 | #define _IO_BYTESIO_READ1_METHODDEF \ |
| 192 | {"read1", (PyCFunction)_io_BytesIO_read1, METH_O, _io_BytesIO_read1__doc__}, |
| 193 | |
| 194 | PyDoc_STRVAR(_io_BytesIO_readline__doc__, |
| 195 | "readline($self, size=None, /)\n" |
| 196 | "--\n" |
| 197 | "\n" |
| 198 | "Next line from the file, as a bytes object.\n" |
| 199 | "\n" |
| 200 | "Retain newline. A non-negative size argument limits the maximum\n" |
| 201 | "number of bytes to return (an incomplete line may be returned then).\n" |
| 202 | "Return an empty bytes object at EOF."); |
| 203 | |
| 204 | #define _IO_BYTESIO_READLINE_METHODDEF \ |
| 205 | {"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__}, |
| 206 | |
| 207 | static PyObject * |
| 208 | _io_BytesIO_readline_impl(bytesio *self, PyObject *arg); |
| 209 | |
| 210 | static PyObject * |
| 211 | _io_BytesIO_readline(bytesio *self, PyObject *args) |
| 212 | { |
| 213 | PyObject *return_value = NULL; |
| 214 | PyObject *arg = Py_None; |
| 215 | |
| 216 | if (!PyArg_UnpackTuple(args, "readline", |
| 217 | 0, 1, |
| 218 | &arg)) |
| 219 | goto exit; |
| 220 | return_value = _io_BytesIO_readline_impl(self, arg); |
| 221 | |
| 222 | exit: |
| 223 | return return_value; |
| 224 | } |
| 225 | |
| 226 | PyDoc_STRVAR(_io_BytesIO_readlines__doc__, |
| 227 | "readlines($self, size=None, /)\n" |
| 228 | "--\n" |
| 229 | "\n" |
| 230 | "List of bytes objects, each a line from the file.\n" |
| 231 | "\n" |
| 232 | "Call readline() repeatedly and return a list of the lines so read.\n" |
| 233 | "The optional size argument, if given, is an approximate bound on the\n" |
| 234 | "total number of bytes in the lines returned."); |
| 235 | |
| 236 | #define _IO_BYTESIO_READLINES_METHODDEF \ |
| 237 | {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__}, |
| 238 | |
| 239 | static PyObject * |
| 240 | _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg); |
| 241 | |
| 242 | static PyObject * |
| 243 | _io_BytesIO_readlines(bytesio *self, PyObject *args) |
| 244 | { |
| 245 | PyObject *return_value = NULL; |
| 246 | PyObject *arg = Py_None; |
| 247 | |
| 248 | if (!PyArg_UnpackTuple(args, "readlines", |
| 249 | 0, 1, |
| 250 | &arg)) |
| 251 | goto exit; |
| 252 | return_value = _io_BytesIO_readlines_impl(self, arg); |
| 253 | |
| 254 | exit: |
| 255 | return return_value; |
| 256 | } |
| 257 | |
| 258 | PyDoc_STRVAR(_io_BytesIO_readinto__doc__, |
| 259 | "readinto($self, buffer, /)\n" |
| 260 | "--\n" |
| 261 | "\n" |
Martin Panter | 6bb91f3 | 2016-05-28 00:41:57 +0000 | [diff] [blame] | 262 | "Read bytes into buffer.\n" |
Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 263 | "\n" |
| 264 | "Returns number of bytes read (0 for EOF), or None if the object\n" |
Martin Panter | 119e502 | 2016-04-16 09:28:57 +0000 | [diff] [blame] | 265 | "is set not to block and has no data to read."); |
Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 266 | |
| 267 | #define _IO_BYTESIO_READINTO_METHODDEF \ |
| 268 | {"readinto", (PyCFunction)_io_BytesIO_readinto, METH_O, _io_BytesIO_readinto__doc__}, |
| 269 | |
| 270 | static PyObject * |
| 271 | _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer); |
| 272 | |
| 273 | static PyObject * |
| 274 | _io_BytesIO_readinto(bytesio *self, PyObject *arg) |
| 275 | { |
| 276 | PyObject *return_value = NULL; |
| 277 | Py_buffer buffer = {NULL, NULL}; |
| 278 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 279 | if (!PyArg_Parse(arg, "w*:readinto", &buffer)) |
Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 280 | goto exit; |
| 281 | return_value = _io_BytesIO_readinto_impl(self, &buffer); |
| 282 | |
| 283 | exit: |
| 284 | /* Cleanup for buffer */ |
| 285 | if (buffer.obj) |
| 286 | PyBuffer_Release(&buffer); |
| 287 | |
| 288 | return return_value; |
| 289 | } |
| 290 | |
| 291 | PyDoc_STRVAR(_io_BytesIO_truncate__doc__, |
| 292 | "truncate($self, size=None, /)\n" |
| 293 | "--\n" |
| 294 | "\n" |
| 295 | "Truncate the file to at most size bytes.\n" |
| 296 | "\n" |
| 297 | "Size defaults to the current file position, as returned by tell().\n" |
| 298 | "The current file position is unchanged. Returns the new size."); |
| 299 | |
| 300 | #define _IO_BYTESIO_TRUNCATE_METHODDEF \ |
| 301 | {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__}, |
| 302 | |
| 303 | static PyObject * |
| 304 | _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg); |
| 305 | |
| 306 | static PyObject * |
| 307 | _io_BytesIO_truncate(bytesio *self, PyObject *args) |
| 308 | { |
| 309 | PyObject *return_value = NULL; |
| 310 | PyObject *arg = Py_None; |
| 311 | |
| 312 | if (!PyArg_UnpackTuple(args, "truncate", |
| 313 | 0, 1, |
| 314 | &arg)) |
| 315 | goto exit; |
| 316 | return_value = _io_BytesIO_truncate_impl(self, arg); |
| 317 | |
| 318 | exit: |
| 319 | return return_value; |
| 320 | } |
| 321 | |
| 322 | PyDoc_STRVAR(_io_BytesIO_seek__doc__, |
| 323 | "seek($self, pos, whence=0, /)\n" |
| 324 | "--\n" |
| 325 | "\n" |
| 326 | "Change stream position.\n" |
| 327 | "\n" |
| 328 | "Seek to byte offset pos relative to position indicated by whence:\n" |
| 329 | " 0 Start of stream (the default). pos should be >= 0;\n" |
| 330 | " 1 Current position - pos may be negative;\n" |
| 331 | " 2 End of stream - pos usually negative.\n" |
| 332 | "Returns the new absolute position."); |
| 333 | |
| 334 | #define _IO_BYTESIO_SEEK_METHODDEF \ |
| 335 | {"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__}, |
| 336 | |
| 337 | static PyObject * |
| 338 | _io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence); |
| 339 | |
| 340 | static PyObject * |
| 341 | _io_BytesIO_seek(bytesio *self, PyObject *args) |
| 342 | { |
| 343 | PyObject *return_value = NULL; |
| 344 | Py_ssize_t pos; |
| 345 | int whence = 0; |
| 346 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 347 | if (!PyArg_ParseTuple(args, "n|i:seek", |
Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 348 | &pos, &whence)) |
| 349 | goto exit; |
| 350 | return_value = _io_BytesIO_seek_impl(self, pos, whence); |
| 351 | |
| 352 | exit: |
| 353 | return return_value; |
| 354 | } |
| 355 | |
| 356 | PyDoc_STRVAR(_io_BytesIO_write__doc__, |
| 357 | "write($self, b, /)\n" |
| 358 | "--\n" |
| 359 | "\n" |
| 360 | "Write bytes to file.\n" |
| 361 | "\n" |
| 362 | "Return the number of bytes written."); |
| 363 | |
| 364 | #define _IO_BYTESIO_WRITE_METHODDEF \ |
| 365 | {"write", (PyCFunction)_io_BytesIO_write, METH_O, _io_BytesIO_write__doc__}, |
| 366 | |
| 367 | PyDoc_STRVAR(_io_BytesIO_writelines__doc__, |
| 368 | "writelines($self, lines, /)\n" |
| 369 | "--\n" |
| 370 | "\n" |
| 371 | "Write lines to the file.\n" |
| 372 | "\n" |
| 373 | "Note that newlines are not added. lines can be any iterable object\n" |
| 374 | "producing bytes-like objects. This is equivalent to calling write() for\n" |
| 375 | "each element."); |
| 376 | |
| 377 | #define _IO_BYTESIO_WRITELINES_METHODDEF \ |
| 378 | {"writelines", (PyCFunction)_io_BytesIO_writelines, METH_O, _io_BytesIO_writelines__doc__}, |
| 379 | |
| 380 | PyDoc_STRVAR(_io_BytesIO_close__doc__, |
| 381 | "close($self, /)\n" |
| 382 | "--\n" |
| 383 | "\n" |
| 384 | "Disable all I/O operations."); |
| 385 | |
| 386 | #define _IO_BYTESIO_CLOSE_METHODDEF \ |
| 387 | {"close", (PyCFunction)_io_BytesIO_close, METH_NOARGS, _io_BytesIO_close__doc__}, |
| 388 | |
| 389 | static PyObject * |
| 390 | _io_BytesIO_close_impl(bytesio *self); |
| 391 | |
| 392 | static PyObject * |
| 393 | _io_BytesIO_close(bytesio *self, PyObject *Py_UNUSED(ignored)) |
| 394 | { |
| 395 | return _io_BytesIO_close_impl(self); |
| 396 | } |
| 397 | |
| 398 | PyDoc_STRVAR(_io_BytesIO___init____doc__, |
| 399 | "BytesIO(initial_bytes=b\'\')\n" |
| 400 | "--\n" |
| 401 | "\n" |
| 402 | "Buffered I/O implementation using an in-memory bytes buffer."); |
| 403 | |
| 404 | static int |
| 405 | _io_BytesIO___init___impl(bytesio *self, PyObject *initvalue); |
| 406 | |
| 407 | static int |
| 408 | _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 409 | { |
| 410 | int return_value = -1; |
| 411 | static char *_keywords[] = {"initial_bytes", NULL}; |
| 412 | PyObject *initvalue = NULL; |
| 413 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 414 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords, |
Serhiy Storchaka | f24131f | 2015-04-16 11:19:43 +0300 | [diff] [blame] | 415 | &initvalue)) |
| 416 | goto exit; |
| 417 | return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue); |
| 418 | |
| 419 | exit: |
| 420 | return return_value; |
| 421 | } |
Martin Panter | 6bb91f3 | 2016-05-28 00:41:57 +0000 | [diff] [blame] | 422 | /*[clinic end generated code: output=60ce2c6272718431 input=a9049054013a1b77]*/ |