blob: 5f2abb03a7099b4110125a703a54ebcec43d0283 [file] [log] [blame]
Serhiy Storchakaf24131f2015-04-16 11:19:43 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
14static PyObject *
15_io_BytesIO_readable_impl(bytesio *self);
16
17static PyObject *
18_io_BytesIO_readable(bytesio *self, PyObject *Py_UNUSED(ignored))
19{
20 return _io_BytesIO_readable_impl(self);
21}
22
23PyDoc_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
32static PyObject *
33_io_BytesIO_writable_impl(bytesio *self);
34
35static PyObject *
36_io_BytesIO_writable(bytesio *self, PyObject *Py_UNUSED(ignored))
37{
38 return _io_BytesIO_writable_impl(self);
39}
40
41PyDoc_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
50static PyObject *
51_io_BytesIO_seekable_impl(bytesio *self);
52
53static PyObject *
54_io_BytesIO_seekable(bytesio *self, PyObject *Py_UNUSED(ignored))
55{
56 return _io_BytesIO_seekable_impl(self);
57}
58
59PyDoc_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
68static PyObject *
69_io_BytesIO_flush_impl(bytesio *self);
70
71static PyObject *
72_io_BytesIO_flush(bytesio *self, PyObject *Py_UNUSED(ignored))
73{
74 return _io_BytesIO_flush_impl(self);
75}
76
77PyDoc_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
86static PyObject *
87_io_BytesIO_getbuffer_impl(bytesio *self);
88
89static PyObject *
90_io_BytesIO_getbuffer(bytesio *self, PyObject *Py_UNUSED(ignored))
91{
92 return _io_BytesIO_getbuffer_impl(self);
93}
94
95PyDoc_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
104static PyObject *
105_io_BytesIO_getvalue_impl(bytesio *self);
106
107static PyObject *
108_io_BytesIO_getvalue(bytesio *self, PyObject *Py_UNUSED(ignored))
109{
110 return _io_BytesIO_getvalue_impl(self);
111}
112
113PyDoc_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
124static PyObject *
125_io_BytesIO_isatty_impl(bytesio *self);
126
127static PyObject *
128_io_BytesIO_isatty(bytesio *self, PyObject *Py_UNUSED(ignored))
129{
130 return _io_BytesIO_isatty_impl(self);
131}
132
133PyDoc_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
142static PyObject *
143_io_BytesIO_tell_impl(bytesio *self);
144
145static PyObject *
146_io_BytesIO_tell(bytesio *self, PyObject *Py_UNUSED(ignored))
147{
148 return _io_BytesIO_tell_impl(self);
149}
150
151PyDoc_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
163static PyObject *
164_io_BytesIO_read_impl(bytesio *self, PyObject *arg);
165
166static 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
178exit:
179 return return_value;
180}
181
182PyDoc_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
194PyDoc_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
207static PyObject *
208_io_BytesIO_readline_impl(bytesio *self, PyObject *arg);
209
210static 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
222exit:
223 return return_value;
224}
225
226PyDoc_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
239static PyObject *
240_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
241
242static 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
254exit:
255 return return_value;
256}
257
258PyDoc_STRVAR(_io_BytesIO_readinto__doc__,
259"readinto($self, buffer, /)\n"
260"--\n"
261"\n"
Martin Panter6bb91f32016-05-28 00:41:57 +0000262"Read bytes into buffer.\n"
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300263"\n"
264"Returns number of bytes read (0 for EOF), or None if the object\n"
Martin Panter119e5022016-04-16 09:28:57 +0000265"is set not to block and has no data to read.");
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300266
267#define _IO_BYTESIO_READINTO_METHODDEF \
268 {"readinto", (PyCFunction)_io_BytesIO_readinto, METH_O, _io_BytesIO_readinto__doc__},
269
270static PyObject *
271_io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer);
272
273static PyObject *
274_io_BytesIO_readinto(bytesio *self, PyObject *arg)
275{
276 PyObject *return_value = NULL;
277 Py_buffer buffer = {NULL, NULL};
278
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300279 if (!PyArg_Parse(arg, "w*:readinto", &buffer))
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300280 goto exit;
281 return_value = _io_BytesIO_readinto_impl(self, &buffer);
282
283exit:
284 /* Cleanup for buffer */
285 if (buffer.obj)
286 PyBuffer_Release(&buffer);
287
288 return return_value;
289}
290
291PyDoc_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
303static PyObject *
304_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg);
305
306static 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
318exit:
319 return return_value;
320}
321
322PyDoc_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
337static PyObject *
338_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);
339
340static 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 Storchaka247789c2015-04-24 00:40:51 +0300347 if (!PyArg_ParseTuple(args, "n|i:seek",
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300348 &pos, &whence))
349 goto exit;
350 return_value = _io_BytesIO_seek_impl(self, pos, whence);
351
352exit:
353 return return_value;
354}
355
356PyDoc_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
367PyDoc_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
380PyDoc_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
389static PyObject *
390_io_BytesIO_close_impl(bytesio *self);
391
392static PyObject *
393_io_BytesIO_close(bytesio *self, PyObject *Py_UNUSED(ignored))
394{
395 return _io_BytesIO_close_impl(self);
396}
397
398PyDoc_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
404static int
405_io_BytesIO___init___impl(bytesio *self, PyObject *initvalue);
406
407static 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 Storchaka247789c2015-04-24 00:40:51 +0300414 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords,
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300415 &initvalue))
416 goto exit;
417 return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
418
419exit:
420 return return_value;
421}
Martin Panter6bb91f32016-05-28 00:41:57 +0000422/*[clinic end generated code: output=60ce2c6272718431 input=a9049054013a1b77]*/