1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__,
6 "readinto($self, buffer, /)\n"
7 "--\n"
8 "\n");
9
10 #define _IO__BUFFEREDIOBASE_READINTO_METHODDEF \
11 {"readinto", (PyCFunction)_io__BufferedIOBase_readinto, METH_O, _io__BufferedIOBase_readinto__doc__},
12
13 static PyObject *
14 _io__BufferedIOBase_readinto_impl(PyObject *self, Py_buffer *buffer);
15
16 static PyObject *
_io__BufferedIOBase_readinto(PyObject * self,PyObject * arg)17 _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
18 {
19 PyObject *return_value = NULL;
20 Py_buffer buffer = {NULL, NULL};
21
22 if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
23 goto exit;
24 }
25 return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
26
27 exit:
28 /* Cleanup for buffer */
29 if (buffer.obj) {
30 PyBuffer_Release(&buffer);
31 }
32
33 return return_value;
34 }
35
36 PyDoc_STRVAR(_io__BufferedIOBase_readinto1__doc__,
37 "readinto1($self, buffer, /)\n"
38 "--\n"
39 "\n");
40
41 #define _IO__BUFFEREDIOBASE_READINTO1_METHODDEF \
42 {"readinto1", (PyCFunction)_io__BufferedIOBase_readinto1, METH_O, _io__BufferedIOBase_readinto1__doc__},
43
44 static PyObject *
45 _io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer);
46
47 static PyObject *
_io__BufferedIOBase_readinto1(PyObject * self,PyObject * arg)48 _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
49 {
50 PyObject *return_value = NULL;
51 Py_buffer buffer = {NULL, NULL};
52
53 if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
54 goto exit;
55 }
56 return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
57
58 exit:
59 /* Cleanup for buffer */
60 if (buffer.obj) {
61 PyBuffer_Release(&buffer);
62 }
63
64 return return_value;
65 }
66
67 PyDoc_STRVAR(_io__BufferedIOBase_detach__doc__,
68 "detach($self, /)\n"
69 "--\n"
70 "\n"
71 "Disconnect this buffer from its underlying raw stream and return it.\n"
72 "\n"
73 "After the raw stream has been detached, the buffer is in an unusable\n"
74 "state.");
75
76 #define _IO__BUFFEREDIOBASE_DETACH_METHODDEF \
77 {"detach", (PyCFunction)_io__BufferedIOBase_detach, METH_NOARGS, _io__BufferedIOBase_detach__doc__},
78
79 static PyObject *
80 _io__BufferedIOBase_detach_impl(PyObject *self);
81
82 static PyObject *
_io__BufferedIOBase_detach(PyObject * self,PyObject * Py_UNUSED (ignored))83 _io__BufferedIOBase_detach(PyObject *self, PyObject *Py_UNUSED(ignored))
84 {
85 return _io__BufferedIOBase_detach_impl(self);
86 }
87
88 PyDoc_STRVAR(_io__Buffered_peek__doc__,
89 "peek($self, size=0, /)\n"
90 "--\n"
91 "\n");
92
93 #define _IO__BUFFERED_PEEK_METHODDEF \
94 {"peek", (PyCFunction)_io__Buffered_peek, METH_VARARGS, _io__Buffered_peek__doc__},
95
96 static PyObject *
97 _io__Buffered_peek_impl(buffered *self, Py_ssize_t size);
98
99 static PyObject *
_io__Buffered_peek(buffered * self,PyObject * args)100 _io__Buffered_peek(buffered *self, PyObject *args)
101 {
102 PyObject *return_value = NULL;
103 Py_ssize_t size = 0;
104
105 if (!PyArg_ParseTuple(args, "|n:peek",
106 &size)) {
107 goto exit;
108 }
109 return_value = _io__Buffered_peek_impl(self, size);
110
111 exit:
112 return return_value;
113 }
114
115 PyDoc_STRVAR(_io__Buffered_read__doc__,
116 "read($self, size=-1, /)\n"
117 "--\n"
118 "\n");
119
120 #define _IO__BUFFERED_READ_METHODDEF \
121 {"read", (PyCFunction)_io__Buffered_read, METH_VARARGS, _io__Buffered_read__doc__},
122
123 static PyObject *
124 _io__Buffered_read_impl(buffered *self, Py_ssize_t n);
125
126 static PyObject *
_io__Buffered_read(buffered * self,PyObject * args)127 _io__Buffered_read(buffered *self, PyObject *args)
128 {
129 PyObject *return_value = NULL;
130 Py_ssize_t n = -1;
131
132 if (!PyArg_ParseTuple(args, "|O&:read",
133 _PyIO_ConvertSsize_t, &n)) {
134 goto exit;
135 }
136 return_value = _io__Buffered_read_impl(self, n);
137
138 exit:
139 return return_value;
140 }
141
142 PyDoc_STRVAR(_io__Buffered_read1__doc__,
143 "read1($self, size, /)\n"
144 "--\n"
145 "\n");
146
147 #define _IO__BUFFERED_READ1_METHODDEF \
148 {"read1", (PyCFunction)_io__Buffered_read1, METH_O, _io__Buffered_read1__doc__},
149
150 static PyObject *
151 _io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
152
153 static PyObject *
_io__Buffered_read1(buffered * self,PyObject * arg)154 _io__Buffered_read1(buffered *self, PyObject *arg)
155 {
156 PyObject *return_value = NULL;
157 Py_ssize_t n;
158
159 if (!PyArg_Parse(arg, "n:read1", &n)) {
160 goto exit;
161 }
162 return_value = _io__Buffered_read1_impl(self, n);
163
164 exit:
165 return return_value;
166 }
167
168 PyDoc_STRVAR(_io__Buffered_readinto__doc__,
169 "readinto($self, buffer, /)\n"
170 "--\n"
171 "\n");
172
173 #define _IO__BUFFERED_READINTO_METHODDEF \
174 {"readinto", (PyCFunction)_io__Buffered_readinto, METH_O, _io__Buffered_readinto__doc__},
175
176 static PyObject *
177 _io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer);
178
179 static PyObject *
_io__Buffered_readinto(buffered * self,PyObject * arg)180 _io__Buffered_readinto(buffered *self, PyObject *arg)
181 {
182 PyObject *return_value = NULL;
183 Py_buffer buffer = {NULL, NULL};
184
185 if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
186 goto exit;
187 }
188 return_value = _io__Buffered_readinto_impl(self, &buffer);
189
190 exit:
191 /* Cleanup for buffer */
192 if (buffer.obj) {
193 PyBuffer_Release(&buffer);
194 }
195
196 return return_value;
197 }
198
199 PyDoc_STRVAR(_io__Buffered_readinto1__doc__,
200 "readinto1($self, buffer, /)\n"
201 "--\n"
202 "\n");
203
204 #define _IO__BUFFERED_READINTO1_METHODDEF \
205 {"readinto1", (PyCFunction)_io__Buffered_readinto1, METH_O, _io__Buffered_readinto1__doc__},
206
207 static PyObject *
208 _io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer);
209
210 static PyObject *
_io__Buffered_readinto1(buffered * self,PyObject * arg)211 _io__Buffered_readinto1(buffered *self, PyObject *arg)
212 {
213 PyObject *return_value = NULL;
214 Py_buffer buffer = {NULL, NULL};
215
216 if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
217 goto exit;
218 }
219 return_value = _io__Buffered_readinto1_impl(self, &buffer);
220
221 exit:
222 /* Cleanup for buffer */
223 if (buffer.obj) {
224 PyBuffer_Release(&buffer);
225 }
226
227 return return_value;
228 }
229
230 PyDoc_STRVAR(_io__Buffered_readline__doc__,
231 "readline($self, size=-1, /)\n"
232 "--\n"
233 "\n");
234
235 #define _IO__BUFFERED_READLINE_METHODDEF \
236 {"readline", (PyCFunction)_io__Buffered_readline, METH_VARARGS, _io__Buffered_readline__doc__},
237
238 static PyObject *
239 _io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
240
241 static PyObject *
_io__Buffered_readline(buffered * self,PyObject * args)242 _io__Buffered_readline(buffered *self, PyObject *args)
243 {
244 PyObject *return_value = NULL;
245 Py_ssize_t size = -1;
246
247 if (!PyArg_ParseTuple(args, "|O&:readline",
248 _PyIO_ConvertSsize_t, &size)) {
249 goto exit;
250 }
251 return_value = _io__Buffered_readline_impl(self, size);
252
253 exit:
254 return return_value;
255 }
256
257 PyDoc_STRVAR(_io__Buffered_seek__doc__,
258 "seek($self, target, whence=0, /)\n"
259 "--\n"
260 "\n");
261
262 #define _IO__BUFFERED_SEEK_METHODDEF \
263 {"seek", (PyCFunction)_io__Buffered_seek, METH_VARARGS, _io__Buffered_seek__doc__},
264
265 static PyObject *
266 _io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
267
268 static PyObject *
_io__Buffered_seek(buffered * self,PyObject * args)269 _io__Buffered_seek(buffered *self, PyObject *args)
270 {
271 PyObject *return_value = NULL;
272 PyObject *targetobj;
273 int whence = 0;
274
275 if (!PyArg_ParseTuple(args, "O|i:seek",
276 &targetobj, &whence)) {
277 goto exit;
278 }
279 return_value = _io__Buffered_seek_impl(self, targetobj, whence);
280
281 exit:
282 return return_value;
283 }
284
285 PyDoc_STRVAR(_io__Buffered_truncate__doc__,
286 "truncate($self, pos=None, /)\n"
287 "--\n"
288 "\n");
289
290 #define _IO__BUFFERED_TRUNCATE_METHODDEF \
291 {"truncate", (PyCFunction)_io__Buffered_truncate, METH_VARARGS, _io__Buffered_truncate__doc__},
292
293 static PyObject *
294 _io__Buffered_truncate_impl(buffered *self, PyObject *pos);
295
296 static PyObject *
_io__Buffered_truncate(buffered * self,PyObject * args)297 _io__Buffered_truncate(buffered *self, PyObject *args)
298 {
299 PyObject *return_value = NULL;
300 PyObject *pos = Py_None;
301
302 if (!PyArg_UnpackTuple(args, "truncate",
303 0, 1,
304 &pos)) {
305 goto exit;
306 }
307 return_value = _io__Buffered_truncate_impl(self, pos);
308
309 exit:
310 return return_value;
311 }
312
313 PyDoc_STRVAR(_io_BufferedReader___init____doc__,
314 "BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
315 "--\n"
316 "\n"
317 "Create a new buffered reader using the given readable raw IO object.");
318
319 static int
320 _io_BufferedReader___init___impl(buffered *self, PyObject *raw,
321 Py_ssize_t buffer_size);
322
323 static int
_io_BufferedReader___init__(PyObject * self,PyObject * args,PyObject * kwargs)324 _io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
325 {
326 int return_value = -1;
327 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
328 static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0};
329 PyObject *raw;
330 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
331
332 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
333 &raw, &buffer_size)) {
334 goto exit;
335 }
336 return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
337
338 exit:
339 return return_value;
340 }
341
342 PyDoc_STRVAR(_io_BufferedWriter___init____doc__,
343 "BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
344 "--\n"
345 "\n"
346 "A buffer for a writeable sequential RawIO object.\n"
347 "\n"
348 "The constructor creates a BufferedWriter for the given writeable raw\n"
349 "stream. If the buffer_size is not given, it defaults to\n"
350 "DEFAULT_BUFFER_SIZE.");
351
352 static int
353 _io_BufferedWriter___init___impl(buffered *self, PyObject *raw,
354 Py_ssize_t buffer_size);
355
356 static int
_io_BufferedWriter___init__(PyObject * self,PyObject * args,PyObject * kwargs)357 _io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
358 {
359 int return_value = -1;
360 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
361 static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0};
362 PyObject *raw;
363 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
364
365 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
366 &raw, &buffer_size)) {
367 goto exit;
368 }
369 return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
370
371 exit:
372 return return_value;
373 }
374
375 PyDoc_STRVAR(_io_BufferedWriter_write__doc__,
376 "write($self, buffer, /)\n"
377 "--\n"
378 "\n");
379
380 #define _IO_BUFFEREDWRITER_WRITE_METHODDEF \
381 {"write", (PyCFunction)_io_BufferedWriter_write, METH_O, _io_BufferedWriter_write__doc__},
382
383 static PyObject *
384 _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer);
385
386 static PyObject *
_io_BufferedWriter_write(buffered * self,PyObject * arg)387 _io_BufferedWriter_write(buffered *self, PyObject *arg)
388 {
389 PyObject *return_value = NULL;
390 Py_buffer buffer = {NULL, NULL};
391
392 if (!PyArg_Parse(arg, "y*:write", &buffer)) {
393 goto exit;
394 }
395 return_value = _io_BufferedWriter_write_impl(self, &buffer);
396
397 exit:
398 /* Cleanup for buffer */
399 if (buffer.obj) {
400 PyBuffer_Release(&buffer);
401 }
402
403 return return_value;
404 }
405
406 PyDoc_STRVAR(_io_BufferedRWPair___init____doc__,
407 "BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE, /)\n"
408 "--\n"
409 "\n"
410 "A buffered reader and writer object together.\n"
411 "\n"
412 "A buffered reader object and buffered writer object put together to\n"
413 "form a sequential IO object that can read and write. This is typically\n"
414 "used with a socket or two-way pipe.\n"
415 "\n"
416 "reader and writer are RawIOBase objects that are readable and\n"
417 "writeable respectively. If the buffer_size is omitted it defaults to\n"
418 "DEFAULT_BUFFER_SIZE.");
419
420 static int
421 _io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader,
422 PyObject *writer, Py_ssize_t buffer_size);
423
424 static int
_io_BufferedRWPair___init__(PyObject * self,PyObject * args,PyObject * kwargs)425 _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
426 {
427 int return_value = -1;
428 PyObject *reader;
429 PyObject *writer;
430 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
431
432 if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
433 !_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
434 goto exit;
435 }
436 if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
437 &reader, &writer, &buffer_size)) {
438 goto exit;
439 }
440 return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
441
442 exit:
443 return return_value;
444 }
445
446 PyDoc_STRVAR(_io_BufferedRandom___init____doc__,
447 "BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
448 "--\n"
449 "\n"
450 "A buffered interface to random access streams.\n"
451 "\n"
452 "The constructor creates a reader and writer for a seekable stream,\n"
453 "raw, given in the first argument. If the buffer_size is omitted it\n"
454 "defaults to DEFAULT_BUFFER_SIZE.");
455
456 static int
457 _io_BufferedRandom___init___impl(buffered *self, PyObject *raw,
458 Py_ssize_t buffer_size);
459
460 static int
_io_BufferedRandom___init__(PyObject * self,PyObject * args,PyObject * kwargs)461 _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
462 {
463 int return_value = -1;
464 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
465 static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0};
466 PyObject *raw;
467 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
468
469 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
470 &raw, &buffer_size)) {
471 goto exit;
472 }
473 return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
474
475 exit:
476 return return_value;
477 }
478 /*[clinic end generated code: output=a956f394ecde4cf9 input=a9049054013a1b77]*/
479