/src/Python-3.8.3/Modules/_io/clinic/iobase.c.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | PyDoc_STRVAR(_io__IOBase_tell__doc__, |
6 | | "tell($self, /)\n" |
7 | | "--\n" |
8 | | "\n" |
9 | | "Return current stream position."); |
10 | | |
11 | | #define _IO__IOBASE_TELL_METHODDEF \ |
12 | | {"tell", (PyCFunction)_io__IOBase_tell, METH_NOARGS, _io__IOBase_tell__doc__}, |
13 | | |
14 | | static PyObject * |
15 | | _io__IOBase_tell_impl(PyObject *self); |
16 | | |
17 | | static PyObject * |
18 | | _io__IOBase_tell(PyObject *self, PyObject *Py_UNUSED(ignored)) |
19 | 0 | { |
20 | 0 | return _io__IOBase_tell_impl(self); |
21 | 0 | } |
22 | | |
23 | | PyDoc_STRVAR(_io__IOBase_flush__doc__, |
24 | | "flush($self, /)\n" |
25 | | "--\n" |
26 | | "\n" |
27 | | "Flush write buffers, if applicable.\n" |
28 | | "\n" |
29 | | "This is not implemented for read-only and non-blocking streams."); |
30 | | |
31 | | #define _IO__IOBASE_FLUSH_METHODDEF \ |
32 | | {"flush", (PyCFunction)_io__IOBase_flush, METH_NOARGS, _io__IOBase_flush__doc__}, |
33 | | |
34 | | static PyObject * |
35 | | _io__IOBase_flush_impl(PyObject *self); |
36 | | |
37 | | static PyObject * |
38 | | _io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
39 | 473 | { |
40 | 473 | return _io__IOBase_flush_impl(self); |
41 | 473 | } |
42 | | |
43 | | PyDoc_STRVAR(_io__IOBase_close__doc__, |
44 | | "close($self, /)\n" |
45 | | "--\n" |
46 | | "\n" |
47 | | "Flush and close the IO object.\n" |
48 | | "\n" |
49 | | "This method has no effect if the file is already closed."); |
50 | | |
51 | | #define _IO__IOBASE_CLOSE_METHODDEF \ |
52 | | {"close", (PyCFunction)_io__IOBase_close, METH_NOARGS, _io__IOBase_close__doc__}, |
53 | | |
54 | | static PyObject * |
55 | | _io__IOBase_close_impl(PyObject *self); |
56 | | |
57 | | static PyObject * |
58 | | _io__IOBase_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
59 | 236 | { |
60 | 236 | return _io__IOBase_close_impl(self); |
61 | 236 | } |
62 | | |
63 | | PyDoc_STRVAR(_io__IOBase_seekable__doc__, |
64 | | "seekable($self, /)\n" |
65 | | "--\n" |
66 | | "\n" |
67 | | "Return whether object supports random access.\n" |
68 | | "\n" |
69 | | "If False, seek(), tell() and truncate() will raise OSError.\n" |
70 | | "This method may need to do a test seek()."); |
71 | | |
72 | | #define _IO__IOBASE_SEEKABLE_METHODDEF \ |
73 | | {"seekable", (PyCFunction)_io__IOBase_seekable, METH_NOARGS, _io__IOBase_seekable__doc__}, |
74 | | |
75 | | static PyObject * |
76 | | _io__IOBase_seekable_impl(PyObject *self); |
77 | | |
78 | | static PyObject * |
79 | | _io__IOBase_seekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
80 | 0 | { |
81 | 0 | return _io__IOBase_seekable_impl(self); |
82 | 0 | } |
83 | | |
84 | | PyDoc_STRVAR(_io__IOBase_readable__doc__, |
85 | | "readable($self, /)\n" |
86 | | "--\n" |
87 | | "\n" |
88 | | "Return whether object was opened for reading.\n" |
89 | | "\n" |
90 | | "If False, read() will raise OSError."); |
91 | | |
92 | | #define _IO__IOBASE_READABLE_METHODDEF \ |
93 | | {"readable", (PyCFunction)_io__IOBase_readable, METH_NOARGS, _io__IOBase_readable__doc__}, |
94 | | |
95 | | static PyObject * |
96 | | _io__IOBase_readable_impl(PyObject *self); |
97 | | |
98 | | static PyObject * |
99 | | _io__IOBase_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
100 | 28 | { |
101 | 28 | return _io__IOBase_readable_impl(self); |
102 | 28 | } |
103 | | |
104 | | PyDoc_STRVAR(_io__IOBase_writable__doc__, |
105 | | "writable($self, /)\n" |
106 | | "--\n" |
107 | | "\n" |
108 | | "Return whether object was opened for writing.\n" |
109 | | "\n" |
110 | | "If False, write() will raise OSError."); |
111 | | |
112 | | #define _IO__IOBASE_WRITABLE_METHODDEF \ |
113 | | {"writable", (PyCFunction)_io__IOBase_writable, METH_NOARGS, _io__IOBase_writable__doc__}, |
114 | | |
115 | | static PyObject * |
116 | | _io__IOBase_writable_impl(PyObject *self); |
117 | | |
118 | | static PyObject * |
119 | | _io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
120 | 15 | { |
121 | 15 | return _io__IOBase_writable_impl(self); |
122 | 15 | } |
123 | | |
124 | | PyDoc_STRVAR(_io__IOBase_fileno__doc__, |
125 | | "fileno($self, /)\n" |
126 | | "--\n" |
127 | | "\n" |
128 | | "Returns underlying file descriptor if one exists.\n" |
129 | | "\n" |
130 | | "OSError is raised if the IO object does not use a file descriptor."); |
131 | | |
132 | | #define _IO__IOBASE_FILENO_METHODDEF \ |
133 | | {"fileno", (PyCFunction)_io__IOBase_fileno, METH_NOARGS, _io__IOBase_fileno__doc__}, |
134 | | |
135 | | static PyObject * |
136 | | _io__IOBase_fileno_impl(PyObject *self); |
137 | | |
138 | | static PyObject * |
139 | | _io__IOBase_fileno(PyObject *self, PyObject *Py_UNUSED(ignored)) |
140 | 0 | { |
141 | 0 | return _io__IOBase_fileno_impl(self); |
142 | 0 | } |
143 | | |
144 | | PyDoc_STRVAR(_io__IOBase_isatty__doc__, |
145 | | "isatty($self, /)\n" |
146 | | "--\n" |
147 | | "\n" |
148 | | "Return whether this is an \'interactive\' stream.\n" |
149 | | "\n" |
150 | | "Return False if it can\'t be determined."); |
151 | | |
152 | | #define _IO__IOBASE_ISATTY_METHODDEF \ |
153 | | {"isatty", (PyCFunction)_io__IOBase_isatty, METH_NOARGS, _io__IOBase_isatty__doc__}, |
154 | | |
155 | | static PyObject * |
156 | | _io__IOBase_isatty_impl(PyObject *self); |
157 | | |
158 | | static PyObject * |
159 | | _io__IOBase_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) |
160 | 0 | { |
161 | 0 | return _io__IOBase_isatty_impl(self); |
162 | 0 | } |
163 | | |
164 | | PyDoc_STRVAR(_io__IOBase_readline__doc__, |
165 | | "readline($self, size=-1, /)\n" |
166 | | "--\n" |
167 | | "\n" |
168 | | "Read and return a line from the stream.\n" |
169 | | "\n" |
170 | | "If size is specified, at most size bytes will be read.\n" |
171 | | "\n" |
172 | | "The line terminator is always b\'\\n\' for binary files; for text\n" |
173 | | "files, the newlines argument to open can be used to select the line\n" |
174 | | "terminator(s) recognized."); |
175 | | |
176 | | #define _IO__IOBASE_READLINE_METHODDEF \ |
177 | | {"readline", (PyCFunction)(void(*)(void))_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__}, |
178 | | |
179 | | static PyObject * |
180 | | _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit); |
181 | | |
182 | | static PyObject * |
183 | | _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
184 | 0 | { |
185 | 0 | PyObject *return_value = NULL; |
186 | 0 | Py_ssize_t limit = -1; |
187 | |
|
188 | 0 | if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
189 | 0 | goto exit; |
190 | 0 | } |
191 | 0 | if (nargs < 1) { |
192 | 0 | goto skip_optional; |
193 | 0 | } |
194 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) { |
195 | 0 | goto exit; |
196 | 0 | } |
197 | 0 | skip_optional: |
198 | 0 | return_value = _io__IOBase_readline_impl(self, limit); |
199 | |
|
200 | 0 | exit: |
201 | 0 | return return_value; |
202 | 0 | } |
203 | | |
204 | | PyDoc_STRVAR(_io__IOBase_readlines__doc__, |
205 | | "readlines($self, hint=-1, /)\n" |
206 | | "--\n" |
207 | | "\n" |
208 | | "Return a list of lines from the stream.\n" |
209 | | "\n" |
210 | | "hint can be specified to control the number of lines read: no more\n" |
211 | | "lines will be read if the total size (in bytes/characters) of all\n" |
212 | | "lines so far exceeds hint."); |
213 | | |
214 | | #define _IO__IOBASE_READLINES_METHODDEF \ |
215 | | {"readlines", (PyCFunction)(void(*)(void))_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__}, |
216 | | |
217 | | static PyObject * |
218 | | _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint); |
219 | | |
220 | | static PyObject * |
221 | | _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
222 | 1 | { |
223 | 1 | PyObject *return_value = NULL; |
224 | 1 | Py_ssize_t hint = -1; |
225 | | |
226 | 1 | if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { |
227 | 0 | goto exit; |
228 | 0 | } |
229 | 1 | if (nargs < 1) { |
230 | 1 | goto skip_optional; |
231 | 1 | } |
232 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) { |
233 | 0 | goto exit; |
234 | 0 | } |
235 | 1 | skip_optional: |
236 | 1 | return_value = _io__IOBase_readlines_impl(self, hint); |
237 | | |
238 | 1 | exit: |
239 | 1 | return return_value; |
240 | 1 | } |
241 | | |
242 | | PyDoc_STRVAR(_io__IOBase_writelines__doc__, |
243 | | "writelines($self, lines, /)\n" |
244 | | "--\n" |
245 | | "\n" |
246 | | "Write a list of lines to stream.\n" |
247 | | "\n" |
248 | | "Line separators are not added, so it is usual for each of the\n" |
249 | | "lines provided to have a line separator at the end."); |
250 | | |
251 | | #define _IO__IOBASE_WRITELINES_METHODDEF \ |
252 | | {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__}, |
253 | | |
254 | | PyDoc_STRVAR(_io__RawIOBase_read__doc__, |
255 | | "read($self, size=-1, /)\n" |
256 | | "--\n" |
257 | | "\n"); |
258 | | |
259 | | #define _IO__RAWIOBASE_READ_METHODDEF \ |
260 | | {"read", (PyCFunction)(void(*)(void))_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__}, |
261 | | |
262 | | static PyObject * |
263 | | _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n); |
264 | | |
265 | | static PyObject * |
266 | | _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
267 | 0 | { |
268 | 0 | PyObject *return_value = NULL; |
269 | 0 | Py_ssize_t n = -1; |
270 | |
|
271 | 0 | if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
272 | 0 | goto exit; |
273 | 0 | } |
274 | 0 | if (nargs < 1) { |
275 | 0 | goto skip_optional; |
276 | 0 | } |
277 | 0 | if (PyFloat_Check(args[0])) { |
278 | 0 | PyErr_SetString(PyExc_TypeError, |
279 | 0 | "integer argument expected, got float" ); |
280 | 0 | goto exit; |
281 | 0 | } |
282 | 0 | { |
283 | 0 | Py_ssize_t ival = -1; |
284 | 0 | PyObject *iobj = PyNumber_Index(args[0]); |
285 | 0 | if (iobj != NULL) { |
286 | 0 | ival = PyLong_AsSsize_t(iobj); |
287 | 0 | Py_DECREF(iobj); |
288 | 0 | } |
289 | 0 | if (ival == -1 && PyErr_Occurred()) { |
290 | 0 | goto exit; |
291 | 0 | } |
292 | 0 | n = ival; |
293 | 0 | } |
294 | 0 | skip_optional: |
295 | 0 | return_value = _io__RawIOBase_read_impl(self, n); |
296 | |
|
297 | 0 | exit: |
298 | 0 | return return_value; |
299 | 0 | } |
300 | | |
301 | | PyDoc_STRVAR(_io__RawIOBase_readall__doc__, |
302 | | "readall($self, /)\n" |
303 | | "--\n" |
304 | | "\n" |
305 | | "Read until EOF, using multiple read() call."); |
306 | | |
307 | | #define _IO__RAWIOBASE_READALL_METHODDEF \ |
308 | | {"readall", (PyCFunction)_io__RawIOBase_readall, METH_NOARGS, _io__RawIOBase_readall__doc__}, |
309 | | |
310 | | static PyObject * |
311 | | _io__RawIOBase_readall_impl(PyObject *self); |
312 | | |
313 | | static PyObject * |
314 | | _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) |
315 | 0 | { |
316 | 0 | return _io__RawIOBase_readall_impl(self); |
317 | 0 | } |
318 | | /*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/ |