/src/cpython/Modules/_io/clinic/iobase.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() |
6 | | #include "pycore_modsupport.h" // _PyArg_CheckPositional() |
7 | | |
8 | | PyDoc_STRVAR(_io__IOBase_seek__doc__, |
9 | | "seek($self, offset, whence=os.SEEK_SET, /)\n" |
10 | | "--\n" |
11 | | "\n" |
12 | | "Change the stream position to the given byte offset.\n" |
13 | | "\n" |
14 | | " offset\n" |
15 | | " The stream position, relative to \'whence\'.\n" |
16 | | " whence\n" |
17 | | " The relative position to seek from.\n" |
18 | | "\n" |
19 | | "The offset is interpreted relative to the position indicated by\n" |
20 | | "whence. Values for whence are:\n" |
21 | | "\n" |
22 | | "* os.SEEK_SET or 0 -- start of stream (the default); offset should\n" |
23 | | " be zero or positive\n" |
24 | | "* os.SEEK_CUR or 1 -- current stream position; offset may be\n" |
25 | | " negative\n" |
26 | | "* os.SEEK_END or 2 -- end of stream; offset is usually negative\n" |
27 | | "\n" |
28 | | "Return the new absolute position."); |
29 | | |
30 | | #define _IO__IOBASE_SEEK_METHODDEF \ |
31 | | {"seek", _PyCFunction_CAST(_io__IOBase_seek), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__IOBase_seek__doc__}, |
32 | | |
33 | | static PyObject * |
34 | | _io__IOBase_seek_impl(PyObject *self, PyTypeObject *cls, |
35 | | int Py_UNUSED(offset), int Py_UNUSED(whence)); |
36 | | |
37 | | static PyObject * |
38 | | _io__IOBase_seek(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
39 | 5 | { |
40 | 5 | PyObject *return_value = NULL; |
41 | 5 | int offset; |
42 | 5 | int whence = 0; |
43 | | |
44 | 5 | if (!_PyArg_NoKwnames("seek", kwnames)) { |
45 | 0 | goto exit; |
46 | 0 | } |
47 | 5 | if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { |
48 | 0 | goto exit; |
49 | 0 | } |
50 | 5 | offset = PyLong_AsInt(args[0]); |
51 | 5 | if (offset == -1 && PyErr_Occurred()) { |
52 | 0 | goto exit; |
53 | 0 | } |
54 | 5 | if (nargs < 2) { |
55 | 0 | goto skip_optional; |
56 | 0 | } |
57 | 5 | whence = PyLong_AsInt(args[1]); |
58 | 5 | if (whence == -1 && PyErr_Occurred()) { |
59 | 0 | goto exit; |
60 | 0 | } |
61 | 5 | skip_optional: |
62 | 5 | return_value = _io__IOBase_seek_impl(self, cls, offset, whence); |
63 | | |
64 | 5 | exit: |
65 | 5 | return return_value; |
66 | 5 | } |
67 | | |
68 | | PyDoc_STRVAR(_io__IOBase_tell__doc__, |
69 | | "tell($self, /)\n" |
70 | | "--\n" |
71 | | "\n" |
72 | | "Return current stream position."); |
73 | | |
74 | | #define _IO__IOBASE_TELL_METHODDEF \ |
75 | | {"tell", (PyCFunction)_io__IOBase_tell, METH_NOARGS, _io__IOBase_tell__doc__}, |
76 | | |
77 | | static PyObject * |
78 | | _io__IOBase_tell_impl(PyObject *self); |
79 | | |
80 | | static PyObject * |
81 | | _io__IOBase_tell(PyObject *self, PyObject *Py_UNUSED(ignored)) |
82 | 1.37M | { |
83 | 1.37M | return _io__IOBase_tell_impl(self); |
84 | 1.37M | } |
85 | | |
86 | | PyDoc_STRVAR(_io__IOBase_truncate__doc__, |
87 | | "truncate($self, size=None, /)\n" |
88 | | "--\n" |
89 | | "\n" |
90 | | "Truncate file to size bytes.\n" |
91 | | "\n" |
92 | | "File pointer is left unchanged. Size defaults to the current IO\n" |
93 | | "position as reported by tell(). Return the new size."); |
94 | | |
95 | | #define _IO__IOBASE_TRUNCATE_METHODDEF \ |
96 | | {"truncate", _PyCFunction_CAST(_io__IOBase_truncate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__IOBase_truncate__doc__}, |
97 | | |
98 | | static PyObject * |
99 | | _io__IOBase_truncate_impl(PyObject *self, PyTypeObject *cls, |
100 | | PyObject *Py_UNUSED(size)); |
101 | | |
102 | | static PyObject * |
103 | | _io__IOBase_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
104 | 0 | { |
105 | 0 | PyObject *return_value = NULL; |
106 | 0 | PyObject *size = Py_None; |
107 | |
|
108 | 0 | if (!_PyArg_NoKwnames("truncate", kwnames)) { |
109 | 0 | goto exit; |
110 | 0 | } |
111 | 0 | if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { |
112 | 0 | goto exit; |
113 | 0 | } |
114 | 0 | if (nargs < 1) { |
115 | 0 | goto skip_optional; |
116 | 0 | } |
117 | 0 | size = args[0]; |
118 | 0 | skip_optional: |
119 | 0 | return_value = _io__IOBase_truncate_impl(self, cls, size); |
120 | |
|
121 | 0 | exit: |
122 | 0 | return return_value; |
123 | 0 | } |
124 | | |
125 | | PyDoc_STRVAR(_io__IOBase_flush__doc__, |
126 | | "flush($self, /)\n" |
127 | | "--\n" |
128 | | "\n" |
129 | | "Flush write buffers, if applicable.\n" |
130 | | "\n" |
131 | | "This is not implemented for read-only and non-blocking streams."); |
132 | | |
133 | | #define _IO__IOBASE_FLUSH_METHODDEF \ |
134 | | {"flush", (PyCFunction)_io__IOBase_flush, METH_NOARGS, _io__IOBase_flush__doc__}, |
135 | | |
136 | | static PyObject * |
137 | | _io__IOBase_flush_impl(PyObject *self); |
138 | | |
139 | | static PyObject * |
140 | | _io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
141 | 1.44M | { |
142 | 1.44M | return _io__IOBase_flush_impl(self); |
143 | 1.44M | } |
144 | | |
145 | | PyDoc_STRVAR(_io__IOBase_closed__doc__, |
146 | | "True if the file is closed."); |
147 | | |
148 | | static int |
149 | | _io__IOBase_closed_get_impl(PyObject *self); |
150 | | |
151 | | static PyObject * |
152 | | _io__IOBase_closed_get(PyObject *self, void *Py_UNUSED(context)) |
153 | 7.17M | { |
154 | 7.17M | PyObject *return_value = NULL; |
155 | 7.17M | int _return_value; |
156 | | |
157 | 7.17M | _return_value = _io__IOBase_closed_get_impl(self); |
158 | 7.17M | if ((_return_value == -1) && PyErr_Occurred()) { |
159 | 0 | goto exit; |
160 | 0 | } |
161 | 7.17M | return_value = PyBool_FromLong((long)_return_value); |
162 | | |
163 | 7.17M | exit: |
164 | 7.17M | return return_value; |
165 | 7.17M | } |
166 | | |
167 | | PyDoc_STRVAR(_io__IOBase__checkClosed__doc__, |
168 | | "_checkClosed($self, /)\n" |
169 | | "--\n" |
170 | | "\n"); |
171 | | |
172 | | #define _IO__IOBASE__CHECKCLOSED_METHODDEF \ |
173 | | {"_checkClosed", (PyCFunction)_io__IOBase__checkClosed, METH_NOARGS, _io__IOBase__checkClosed__doc__}, |
174 | | |
175 | | static PyObject * |
176 | | _io__IOBase__checkClosed_impl(PyObject *self); |
177 | | |
178 | | static PyObject * |
179 | | _io__IOBase__checkClosed(PyObject *self, PyObject *Py_UNUSED(ignored)) |
180 | 0 | { |
181 | 0 | return _io__IOBase__checkClosed_impl(self); |
182 | 0 | } |
183 | | |
184 | | PyDoc_STRVAR(_io__IOBase__checkSeekable__doc__, |
185 | | "_checkSeekable($self, /)\n" |
186 | | "--\n" |
187 | | "\n"); |
188 | | |
189 | | #define _IO__IOBASE__CHECKSEEKABLE_METHODDEF \ |
190 | | {"_checkSeekable", (PyCFunction)_io__IOBase__checkSeekable, METH_NOARGS, _io__IOBase__checkSeekable__doc__}, |
191 | | |
192 | | static PyObject * |
193 | | _io__IOBase__checkSeekable_impl(PyObject *self); |
194 | | |
195 | | static PyObject * |
196 | | _io__IOBase__checkSeekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
197 | 0 | { |
198 | 0 | return _io__IOBase__checkSeekable_impl(self); |
199 | 0 | } |
200 | | |
201 | | PyDoc_STRVAR(_io__IOBase__checkReadable__doc__, |
202 | | "_checkReadable($self, /)\n" |
203 | | "--\n" |
204 | | "\n"); |
205 | | |
206 | | #define _IO__IOBASE__CHECKREADABLE_METHODDEF \ |
207 | | {"_checkReadable", (PyCFunction)_io__IOBase__checkReadable, METH_NOARGS, _io__IOBase__checkReadable__doc__}, |
208 | | |
209 | | static PyObject * |
210 | | _io__IOBase__checkReadable_impl(PyObject *self); |
211 | | |
212 | | static PyObject * |
213 | | _io__IOBase__checkReadable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
214 | 0 | { |
215 | 0 | return _io__IOBase__checkReadable_impl(self); |
216 | 0 | } |
217 | | |
218 | | PyDoc_STRVAR(_io__IOBase__checkWritable__doc__, |
219 | | "_checkWritable($self, /)\n" |
220 | | "--\n" |
221 | | "\n"); |
222 | | |
223 | | #define _IO__IOBASE__CHECKWRITABLE_METHODDEF \ |
224 | | {"_checkWritable", (PyCFunction)_io__IOBase__checkWritable, METH_NOARGS, _io__IOBase__checkWritable__doc__}, |
225 | | |
226 | | static PyObject * |
227 | | _io__IOBase__checkWritable_impl(PyObject *self); |
228 | | |
229 | | static PyObject * |
230 | | _io__IOBase__checkWritable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
231 | 0 | { |
232 | 0 | return _io__IOBase__checkWritable_impl(self); |
233 | 0 | } |
234 | | |
235 | | PyDoc_STRVAR(_io__IOBase_close__doc__, |
236 | | "close($self, /)\n" |
237 | | "--\n" |
238 | | "\n" |
239 | | "Flush and close the IO object.\n" |
240 | | "\n" |
241 | | "This method has no effect if the file is already closed."); |
242 | | |
243 | | #define _IO__IOBASE_CLOSE_METHODDEF \ |
244 | | {"close", (PyCFunction)_io__IOBase_close, METH_NOARGS, _io__IOBase_close__doc__}, |
245 | | |
246 | | static PyObject * |
247 | | _io__IOBase_close_impl(PyObject *self); |
248 | | |
249 | | static PyObject * |
250 | | _io__IOBase_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
251 | 65.1k | { |
252 | 65.1k | return _io__IOBase_close_impl(self); |
253 | 65.1k | } |
254 | | |
255 | | PyDoc_STRVAR(_io__IOBase_seekable__doc__, |
256 | | "seekable($self, /)\n" |
257 | | "--\n" |
258 | | "\n" |
259 | | "Return whether object supports random access.\n" |
260 | | "\n" |
261 | | "If False, seek(), tell() and truncate() will raise OSError.\n" |
262 | | "This method may need to do a test seek()."); |
263 | | |
264 | | #define _IO__IOBASE_SEEKABLE_METHODDEF \ |
265 | | {"seekable", (PyCFunction)_io__IOBase_seekable, METH_NOARGS, _io__IOBase_seekable__doc__}, |
266 | | |
267 | | static PyObject * |
268 | | _io__IOBase_seekable_impl(PyObject *self); |
269 | | |
270 | | static PyObject * |
271 | | _io__IOBase_seekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
272 | 0 | { |
273 | 0 | return _io__IOBase_seekable_impl(self); |
274 | 0 | } |
275 | | |
276 | | PyDoc_STRVAR(_io__IOBase_readable__doc__, |
277 | | "readable($self, /)\n" |
278 | | "--\n" |
279 | | "\n" |
280 | | "Return whether object was opened for reading.\n" |
281 | | "\n" |
282 | | "If False, read() will raise OSError."); |
283 | | |
284 | | #define _IO__IOBASE_READABLE_METHODDEF \ |
285 | | {"readable", (PyCFunction)_io__IOBase_readable, METH_NOARGS, _io__IOBase_readable__doc__}, |
286 | | |
287 | | static PyObject * |
288 | | _io__IOBase_readable_impl(PyObject *self); |
289 | | |
290 | | static PyObject * |
291 | | _io__IOBase_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
292 | 75 | { |
293 | 75 | return _io__IOBase_readable_impl(self); |
294 | 75 | } |
295 | | |
296 | | PyDoc_STRVAR(_io__IOBase_writable__doc__, |
297 | | "writable($self, /)\n" |
298 | | "--\n" |
299 | | "\n" |
300 | | "Return whether object was opened for writing.\n" |
301 | | "\n" |
302 | | "If False, write() will raise OSError."); |
303 | | |
304 | | #define _IO__IOBASE_WRITABLE_METHODDEF \ |
305 | | {"writable", (PyCFunction)_io__IOBase_writable, METH_NOARGS, _io__IOBase_writable__doc__}, |
306 | | |
307 | | static PyObject * |
308 | | _io__IOBase_writable_impl(PyObject *self); |
309 | | |
310 | | static PyObject * |
311 | | _io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
312 | 55 | { |
313 | 55 | return _io__IOBase_writable_impl(self); |
314 | 55 | } |
315 | | |
316 | | PyDoc_STRVAR(_io__IOBase___enter____doc__, |
317 | | "__enter__($self, /)\n" |
318 | | "--\n" |
319 | | "\n" |
320 | | "Context management protocol. Returns the stream itself."); |
321 | | |
322 | | #define _IO__IOBASE___ENTER___METHODDEF \ |
323 | | {"__enter__", (PyCFunction)_io__IOBase___enter__, METH_NOARGS, _io__IOBase___enter____doc__}, |
324 | | |
325 | | static PyObject * |
326 | | _io__IOBase___enter___impl(PyObject *self); |
327 | | |
328 | | static PyObject * |
329 | | _io__IOBase___enter__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
330 | 50.8k | { |
331 | 50.8k | return _io__IOBase___enter___impl(self); |
332 | 50.8k | } |
333 | | |
334 | | PyDoc_STRVAR(_io__IOBase___exit____doc__, |
335 | | "__exit__($self, /, *args)\n" |
336 | | "--\n" |
337 | | "\n" |
338 | | "Context management protocol. Calls close()."); |
339 | | |
340 | | #define _IO__IOBASE___EXIT___METHODDEF \ |
341 | | {"__exit__", _PyCFunction_CAST(_io__IOBase___exit__), METH_FASTCALL, _io__IOBase___exit____doc__}, |
342 | | |
343 | | static PyObject * |
344 | | _io__IOBase___exit___impl(PyObject *self, PyObject *args); |
345 | | |
346 | | static PyObject * |
347 | | _io__IOBase___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
348 | 50.8k | { |
349 | 50.8k | PyObject *return_value = NULL; |
350 | 50.8k | PyObject *__clinic_args = NULL; |
351 | | |
352 | 50.8k | __clinic_args = PyTuple_FromArray(args, nargs); |
353 | 50.8k | if (__clinic_args == NULL) { |
354 | 0 | goto exit; |
355 | 0 | } |
356 | 50.8k | return_value = _io__IOBase___exit___impl(self, __clinic_args); |
357 | | |
358 | 50.8k | exit: |
359 | | /* Cleanup for args */ |
360 | 50.8k | Py_XDECREF(__clinic_args); |
361 | | |
362 | 50.8k | return return_value; |
363 | 50.8k | } |
364 | | |
365 | | PyDoc_STRVAR(_io__IOBase_fileno__doc__, |
366 | | "fileno($self, /)\n" |
367 | | "--\n" |
368 | | "\n" |
369 | | "Return underlying file descriptor if one exists.\n" |
370 | | "\n" |
371 | | "Raise OSError if the IO object does not use a file descriptor."); |
372 | | |
373 | | #define _IO__IOBASE_FILENO_METHODDEF \ |
374 | | {"fileno", _PyCFunction_CAST(_io__IOBase_fileno), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__IOBase_fileno__doc__}, |
375 | | |
376 | | static PyObject * |
377 | | _io__IOBase_fileno_impl(PyObject *self, PyTypeObject *cls); |
378 | | |
379 | | static PyObject * |
380 | | _io__IOBase_fileno(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
381 | 0 | { |
382 | 0 | if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
383 | 0 | PyErr_SetString(PyExc_TypeError, "fileno() takes no arguments"); |
384 | 0 | return NULL; |
385 | 0 | } |
386 | 0 | return _io__IOBase_fileno_impl(self, cls); |
387 | 0 | } |
388 | | |
389 | | PyDoc_STRVAR(_io__IOBase_isatty__doc__, |
390 | | "isatty($self, /)\n" |
391 | | "--\n" |
392 | | "\n" |
393 | | "Return whether this is an \'interactive\' stream.\n" |
394 | | "\n" |
395 | | "Return False if it can\'t be determined."); |
396 | | |
397 | | #define _IO__IOBASE_ISATTY_METHODDEF \ |
398 | | {"isatty", (PyCFunction)_io__IOBase_isatty, METH_NOARGS, _io__IOBase_isatty__doc__}, |
399 | | |
400 | | static PyObject * |
401 | | _io__IOBase_isatty_impl(PyObject *self); |
402 | | |
403 | | static PyObject * |
404 | | _io__IOBase_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) |
405 | 0 | { |
406 | 0 | return _io__IOBase_isatty_impl(self); |
407 | 0 | } |
408 | | |
409 | | PyDoc_STRVAR(_io__IOBase_readline__doc__, |
410 | | "readline($self, size=-1, /)\n" |
411 | | "--\n" |
412 | | "\n" |
413 | | "Read and return a line from the stream.\n" |
414 | | "\n" |
415 | | "If size is specified, at most size bytes will be read.\n" |
416 | | "\n" |
417 | | "The line terminator is always b\'\\n\' for binary files; for text\n" |
418 | | "files, the newlines argument to open can be used to select the line\n" |
419 | | "terminator(s) recognized."); |
420 | | |
421 | | #define _IO__IOBASE_READLINE_METHODDEF \ |
422 | | {"readline", _PyCFunction_CAST(_io__IOBase_readline), METH_FASTCALL, _io__IOBase_readline__doc__}, |
423 | | |
424 | | static PyObject * |
425 | | _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit); |
426 | | |
427 | | static PyObject * |
428 | | _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
429 | 0 | { |
430 | 0 | PyObject *return_value = NULL; |
431 | 0 | Py_ssize_t limit = -1; |
432 | |
|
433 | 0 | if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
434 | 0 | goto exit; |
435 | 0 | } |
436 | 0 | if (nargs < 1) { |
437 | 0 | goto skip_optional; |
438 | 0 | } |
439 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) { |
440 | 0 | goto exit; |
441 | 0 | } |
442 | 0 | skip_optional: |
443 | 0 | return_value = _io__IOBase_readline_impl(self, limit); |
444 | |
|
445 | 0 | exit: |
446 | 0 | return return_value; |
447 | 0 | } |
448 | | |
449 | | PyDoc_STRVAR(_io__IOBase_readlines__doc__, |
450 | | "readlines($self, hint=-1, /)\n" |
451 | | "--\n" |
452 | | "\n" |
453 | | "Return a list of lines from the stream.\n" |
454 | | "\n" |
455 | | "hint can be specified to control the number of lines read: no more\n" |
456 | | "lines will be read if the total size (in bytes/characters) of all\n" |
457 | | "lines so far exceeds hint."); |
458 | | |
459 | | #define _IO__IOBASE_READLINES_METHODDEF \ |
460 | | {"readlines", _PyCFunction_CAST(_io__IOBase_readlines), METH_FASTCALL, _io__IOBase_readlines__doc__}, |
461 | | |
462 | | static PyObject * |
463 | | _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint); |
464 | | |
465 | | static PyObject * |
466 | | _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
467 | 38.0k | { |
468 | 38.0k | PyObject *return_value = NULL; |
469 | 38.0k | Py_ssize_t hint = -1; |
470 | | |
471 | 38.0k | if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { |
472 | 0 | goto exit; |
473 | 0 | } |
474 | 38.0k | if (nargs < 1) { |
475 | 38.0k | goto skip_optional; |
476 | 38.0k | } |
477 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) { |
478 | 0 | goto exit; |
479 | 0 | } |
480 | 38.0k | skip_optional: |
481 | 38.0k | return_value = _io__IOBase_readlines_impl(self, hint); |
482 | | |
483 | 38.0k | exit: |
484 | 38.0k | return return_value; |
485 | 38.0k | } |
486 | | |
487 | | PyDoc_STRVAR(_io__IOBase_writelines__doc__, |
488 | | "writelines($self, lines, /)\n" |
489 | | "--\n" |
490 | | "\n" |
491 | | "Write a list of lines to stream.\n" |
492 | | "\n" |
493 | | "Line separators are not added, so it is usual for each of the\n" |
494 | | "lines provided to have a line separator at the end."); |
495 | | |
496 | | #define _IO__IOBASE_WRITELINES_METHODDEF \ |
497 | | {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__}, |
498 | | |
499 | | PyDoc_STRVAR(_io__RawIOBase_read__doc__, |
500 | | "read($self, size=-1, /)\n" |
501 | | "--\n" |
502 | | "\n"); |
503 | | |
504 | | #define _IO__RAWIOBASE_READ_METHODDEF \ |
505 | | {"read", _PyCFunction_CAST(_io__RawIOBase_read), METH_FASTCALL, _io__RawIOBase_read__doc__}, |
506 | | |
507 | | static PyObject * |
508 | | _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n); |
509 | | |
510 | | static PyObject * |
511 | | _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
512 | 0 | { |
513 | 0 | PyObject *return_value = NULL; |
514 | 0 | Py_ssize_t n = -1; |
515 | |
|
516 | 0 | if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
517 | 0 | goto exit; |
518 | 0 | } |
519 | 0 | if (nargs < 1) { |
520 | 0 | goto skip_optional; |
521 | 0 | } |
522 | 0 | { |
523 | 0 | Py_ssize_t ival = -1; |
524 | 0 | PyObject *iobj = _PyNumber_Index(args[0]); |
525 | 0 | if (iobj != NULL) { |
526 | 0 | ival = PyLong_AsSsize_t(iobj); |
527 | 0 | Py_DECREF(iobj); |
528 | 0 | } |
529 | 0 | if (ival == -1 && PyErr_Occurred()) { |
530 | 0 | goto exit; |
531 | 0 | } |
532 | 0 | n = ival; |
533 | 0 | } |
534 | 0 | skip_optional: |
535 | 0 | return_value = _io__RawIOBase_read_impl(self, n); |
536 | |
|
537 | 0 | exit: |
538 | 0 | return return_value; |
539 | 0 | } |
540 | | |
541 | | PyDoc_STRVAR(_io__RawIOBase_readall__doc__, |
542 | | "readall($self, /)\n" |
543 | | "--\n" |
544 | | "\n" |
545 | | "Read until EOF, using multiple read() call."); |
546 | | |
547 | | #define _IO__RAWIOBASE_READALL_METHODDEF \ |
548 | | {"readall", (PyCFunction)_io__RawIOBase_readall, METH_NOARGS, _io__RawIOBase_readall__doc__}, |
549 | | |
550 | | static PyObject * |
551 | | _io__RawIOBase_readall_impl(PyObject *self); |
552 | | |
553 | | static PyObject * |
554 | | _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) |
555 | 0 | { |
556 | 0 | return _io__RawIOBase_readall_impl(self); |
557 | 0 | } |
558 | | |
559 | | PyDoc_STRVAR(_io__RawIOBase_readinto__doc__, |
560 | | "readinto($self, buffer, /)\n" |
561 | | "--\n" |
562 | | "\n"); |
563 | | |
564 | | #define _IO__RAWIOBASE_READINTO_METHODDEF \ |
565 | | {"readinto", (PyCFunction)_io__RawIOBase_readinto, METH_O, _io__RawIOBase_readinto__doc__}, |
566 | | |
567 | | PyDoc_STRVAR(_io__RawIOBase_write__doc__, |
568 | | "write($self, buffer, /)\n" |
569 | | "--\n" |
570 | | "\n"); |
571 | | |
572 | | #define _IO__RAWIOBASE_WRITE_METHODDEF \ |
573 | | {"write", (PyCFunction)_io__RawIOBase_write, METH_O, _io__RawIOBase_write__doc__}, |
574 | | #define _IO__IOBASE_CLOSED_GETSETDEF {"closed", (getter)_io__IOBase_closed_get, (setter)NULL, _io__IOBase_closed__doc__}, |
575 | | |
576 | | /*[clinic end generated code: output=fd729b0ef2ad52b8 input=a9049054013a1b77]*/ |