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_FASTCALL, _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 * const * args,Py_ssize_t nargs)100 _io__Buffered_peek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
101 {
102 PyObject *return_value = NULL;
103 Py_ssize_t size = 0;
104
105 if (!_PyArg_ParseStack(args, nargs, "|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_FASTCALL, _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 * const * args,Py_ssize_t nargs)127 _io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs)
128 {
129 PyObject *return_value = NULL;
130 Py_ssize_t n = -1;
131
132 if (!_PyArg_ParseStack(args, nargs, "|O&:read",
133 _Py_convert_optional_to_ssize_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=-1, /)\n"
144 "--\n"
145 "\n");
146
147 #define _IO__BUFFERED_READ1_METHODDEF \
148 {"read1", (PyCFunction)_io__Buffered_read1, METH_FASTCALL, _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 * const * args,Py_ssize_t nargs)154 _io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs)
155 {
156 PyObject *return_value = NULL;
157 Py_ssize_t n = -1;
158
159 if (!_PyArg_ParseStack(args, nargs, "|n:read1",
160 &n)) {
161 goto exit;
162 }
163 return_value = _io__Buffered_read1_impl(self, n);
164
165 exit:
166 return return_value;
167 }
168
169 PyDoc_STRVAR(_io__Buffered_readinto__doc__,
170 "readinto($self, buffer, /)\n"
171 "--\n"
172 "\n");
173
174 #define _IO__BUFFERED_READINTO_METHODDEF \
175 {"readinto", (PyCFunction)_io__Buffered_readinto, METH_O, _io__Buffered_readinto__doc__},
176
177 static PyObject *
178 _io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer);
179
180 static PyObject *
_io__Buffered_readinto(buffered * self,PyObject * arg)181 _io__Buffered_readinto(buffered *self, PyObject *arg)
182 {
183 PyObject *return_value = NULL;
184 Py_buffer buffer = {NULL, NULL};
185
186 if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
187 goto exit;
188 }
189 return_value = _io__Buffered_readinto_impl(self, &buffer);
190
191 exit:
192 /* Cleanup for buffer */
193 if (buffer.obj) {
194 PyBuffer_Release(&buffer);
195 }
196
197 return return_value;
198 }
199
200 PyDoc_STRVAR(_io__Buffered_readinto1__doc__,
201 "readinto1($self, buffer, /)\n"
202 "--\n"
203 "\n");
204
205 #define _IO__BUFFERED_READINTO1_METHODDEF \
206 {"readinto1", (PyCFunction)_io__Buffered_readinto1, METH_O, _io__Buffered_readinto1__doc__},
207
208 static PyObject *
209 _io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer);
210
211 static PyObject *
_io__Buffered_readinto1(buffered * self,PyObject * arg)212 _io__Buffered_readinto1(buffered *self, PyObject *arg)
213 {
214 PyObject *return_value = NULL;
215 Py_buffer buffer = {NULL, NULL};
216
217 if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
218 goto exit;
219 }
220 return_value = _io__Buffered_readinto1_impl(self, &buffer);
221
222 exit:
223 /* Cleanup for buffer */
224 if (buffer.obj) {
225 PyBuffer_Release(&buffer);
226 }
227
228 return return_value;
229 }
230
231 PyDoc_STRVAR(_io__Buffered_readline__doc__,
232 "readline($self, size=-1, /)\n"
233 "--\n"
234 "\n");
235
236 #define _IO__BUFFERED_READLINE_METHODDEF \
237 {"readline", (PyCFunction)_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__},
238
239 static PyObject *
240 _io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
241
242 static PyObject *
_io__Buffered_readline(buffered * self,PyObject * const * args,Py_ssize_t nargs)243 _io__Buffered_readline(buffered *self, PyObject *const *args, Py_ssize_t nargs)
244 {
245 PyObject *return_value = NULL;
246 Py_ssize_t size = -1;
247
248 if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
249 _Py_convert_optional_to_ssize_t, &size)) {
250 goto exit;
251 }
252 return_value = _io__Buffered_readline_impl(self, size);
253
254 exit:
255 return return_value;
256 }
257
258 PyDoc_STRVAR(_io__Buffered_seek__doc__,
259 "seek($self, target, whence=0, /)\n"
260 "--\n"
261 "\n");
262
263 #define _IO__BUFFERED_SEEK_METHODDEF \
264 {"seek", (PyCFunction)_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__},
265
266 static PyObject *
267 _io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
268
269 static PyObject *
_io__Buffered_seek(buffered * self,PyObject * const * args,Py_ssize_t nargs)270 _io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
271 {
272 PyObject *return_value = NULL;
273 PyObject *targetobj;
274 int whence = 0;
275
276 if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
277 &targetobj, &whence)) {
278 goto exit;
279 }
280 return_value = _io__Buffered_seek_impl(self, targetobj, whence);
281
282 exit:
283 return return_value;
284 }
285
286 PyDoc_STRVAR(_io__Buffered_truncate__doc__,
287 "truncate($self, pos=None, /)\n"
288 "--\n"
289 "\n");
290
291 #define _IO__BUFFERED_TRUNCATE_METHODDEF \
292 {"truncate", (PyCFunction)_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__},
293
294 static PyObject *
295 _io__Buffered_truncate_impl(buffered *self, PyObject *pos);
296
297 static PyObject *
_io__Buffered_truncate(buffered * self,PyObject * const * args,Py_ssize_t nargs)298 _io__Buffered_truncate(buffered *self, PyObject *const *args, Py_ssize_t nargs)
299 {
300 PyObject *return_value = NULL;
301 PyObject *pos = Py_None;
302
303 if (!_PyArg_UnpackStack(args, nargs, "truncate",
304 0, 1,
305 &pos)) {
306 goto exit;
307 }
308 return_value = _io__Buffered_truncate_impl(self, pos);
309
310 exit:
311 return return_value;
312 }
313
314 PyDoc_STRVAR(_io_BufferedReader___init____doc__,
315 "BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
316 "--\n"
317 "\n"
318 "Create a new buffered reader using the given readable raw IO object.");
319
320 static int
321 _io_BufferedReader___init___impl(buffered *self, PyObject *raw,
322 Py_ssize_t buffer_size);
323
324 static int
_io_BufferedReader___init__(PyObject * self,PyObject * args,PyObject * kwargs)325 _io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
326 {
327 int return_value = -1;
328 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
329 static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0};
330 PyObject *raw;
331 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
332
333 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
334 &raw, &buffer_size)) {
335 goto exit;
336 }
337 return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
338
339 exit:
340 return return_value;
341 }
342
343 PyDoc_STRVAR(_io_BufferedWriter___init____doc__,
344 "BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
345 "--\n"
346 "\n"
347 "A buffer for a writeable sequential RawIO object.\n"
348 "\n"
349 "The constructor creates a BufferedWriter for the given writeable raw\n"
350 "stream. If the buffer_size is not given, it defaults to\n"
351 "DEFAULT_BUFFER_SIZE.");
352
353 static int
354 _io_BufferedWriter___init___impl(buffered *self, PyObject *raw,
355 Py_ssize_t buffer_size);
356
357 static int
_io_BufferedWriter___init__(PyObject * self,PyObject * args,PyObject * kwargs)358 _io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
359 {
360 int return_value = -1;
361 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
362 static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0};
363 PyObject *raw;
364 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
365
366 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
367 &raw, &buffer_size)) {
368 goto exit;
369 }
370 return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
371
372 exit:
373 return return_value;
374 }
375
376 PyDoc_STRVAR(_io_BufferedWriter_write__doc__,
377 "write($self, buffer, /)\n"
378 "--\n"
379 "\n");
380
381 #define _IO_BUFFEREDWRITER_WRITE_METHODDEF \
382 {"write", (PyCFunction)_io_BufferedWriter_write, METH_O, _io_BufferedWriter_write__doc__},
383
384 static PyObject *
385 _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer);
386
387 static PyObject *
_io_BufferedWriter_write(buffered * self,PyObject * arg)388 _io_BufferedWriter_write(buffered *self, PyObject *arg)
389 {
390 PyObject *return_value = NULL;
391 Py_buffer buffer = {NULL, NULL};
392
393 if (!PyArg_Parse(arg, "y*:write", &buffer)) {
394 goto exit;
395 }
396 return_value = _io_BufferedWriter_write_impl(self, &buffer);
397
398 exit:
399 /* Cleanup for buffer */
400 if (buffer.obj) {
401 PyBuffer_Release(&buffer);
402 }
403
404 return return_value;
405 }
406
407 PyDoc_STRVAR(_io_BufferedRWPair___init____doc__,
408 "BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE, /)\n"
409 "--\n"
410 "\n"
411 "A buffered reader and writer object together.\n"
412 "\n"
413 "A buffered reader object and buffered writer object put together to\n"
414 "form a sequential IO object that can read and write. This is typically\n"
415 "used with a socket or two-way pipe.\n"
416 "\n"
417 "reader and writer are RawIOBase objects that are readable and\n"
418 "writeable respectively. If the buffer_size is omitted it defaults to\n"
419 "DEFAULT_BUFFER_SIZE.");
420
421 static int
422 _io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader,
423 PyObject *writer, Py_ssize_t buffer_size);
424
425 static int
_io_BufferedRWPair___init__(PyObject * self,PyObject * args,PyObject * kwargs)426 _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
427 {
428 int return_value = -1;
429 PyObject *reader;
430 PyObject *writer;
431 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
432
433 if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
434 !_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
435 goto exit;
436 }
437 if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
438 &reader, &writer, &buffer_size)) {
439 goto exit;
440 }
441 return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
442
443 exit:
444 return return_value;
445 }
446
447 PyDoc_STRVAR(_io_BufferedRandom___init____doc__,
448 "BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
449 "--\n"
450 "\n"
451 "A buffered interface to random access streams.\n"
452 "\n"
453 "The constructor creates a reader and writer for a seekable stream,\n"
454 "raw, given in the first argument. If the buffer_size is omitted it\n"
455 "defaults to DEFAULT_BUFFER_SIZE.");
456
457 static int
458 _io_BufferedRandom___init___impl(buffered *self, PyObject *raw,
459 Py_ssize_t buffer_size);
460
461 static int
_io_BufferedRandom___init__(PyObject * self,PyObject * args,PyObject * kwargs)462 _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
463 {
464 int return_value = -1;
465 static const char * const _keywords[] = {"raw", "buffer_size", NULL};
466 static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0};
467 PyObject *raw;
468 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
469
470 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
471 &raw, &buffer_size)) {
472 goto exit;
473 }
474 return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
475
476 exit:
477 return return_value;
478 }
479 /*[clinic end generated code: output=9a20dd4eaabb5d58 input=a9049054013a1b77]*/
480