/src/Python-3.8.3/Modules/_io/clinic/textio.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_IncrementalNewlineDecoder___init____doc__, |
6 | | "IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n" |
7 | | "--\n" |
8 | | "\n" |
9 | | "Codec used when reading a file in universal newlines mode.\n" |
10 | | "\n" |
11 | | "It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n" |
12 | | "It also records the types of newlines encountered. When used with\n" |
13 | | "translate=False, it ensures that the newline sequence is returned in\n" |
14 | | "one piece. When used with decoder=None, it expects unicode strings as\n" |
15 | | "decode input and translates newlines without first invoking an external\n" |
16 | | "decoder."); |
17 | | |
18 | | static int |
19 | | _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self, |
20 | | PyObject *decoder, int translate, |
21 | | PyObject *errors); |
22 | | |
23 | | static int |
24 | | _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
25 | 1 | { |
26 | 1 | int return_value = -1; |
27 | 1 | static const char * const _keywords[] = {"decoder", "translate", "errors", NULL}; |
28 | 1 | static _PyArg_Parser _parser = {NULL, _keywords, "IncrementalNewlineDecoder", 0}; |
29 | 1 | PyObject *argsbuf[3]; |
30 | 1 | PyObject * const *fastargs; |
31 | 1 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
32 | 1 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; |
33 | 1 | PyObject *decoder; |
34 | 1 | int translate; |
35 | 1 | PyObject *errors = NULL; |
36 | | |
37 | 1 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf); |
38 | 1 | if (!fastargs) { |
39 | 0 | goto exit; |
40 | 0 | } |
41 | 1 | decoder = fastargs[0]; |
42 | 1 | if (PyFloat_Check(fastargs[1])) { |
43 | 0 | PyErr_SetString(PyExc_TypeError, |
44 | 0 | "integer argument expected, got float" ); |
45 | 0 | goto exit; |
46 | 0 | } |
47 | 1 | translate = _PyLong_AsInt(fastargs[1]); |
48 | 1 | if (translate == -1 && PyErr_Occurred()) { |
49 | 0 | goto exit; |
50 | 0 | } |
51 | 1 | if (!noptargs) { |
52 | 1 | goto skip_optional_pos; |
53 | 1 | } |
54 | 0 | errors = fastargs[2]; |
55 | 1 | skip_optional_pos: |
56 | 1 | return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); |
57 | | |
58 | 1 | exit: |
59 | 1 | return return_value; |
60 | 1 | } |
61 | | |
62 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, |
63 | | "decode($self, /, input, final=False)\n" |
64 | | "--\n" |
65 | | "\n"); |
66 | | |
67 | | #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ |
68 | | {"decode", (PyCFunction)(void(*)(void))_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, |
69 | | |
70 | | static PyObject * |
71 | | _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, |
72 | | PyObject *input, int final); |
73 | | |
74 | | static PyObject * |
75 | | _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
76 | 0 | { |
77 | 0 | PyObject *return_value = NULL; |
78 | 0 | static const char * const _keywords[] = {"input", "final", NULL}; |
79 | 0 | static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; |
80 | 0 | PyObject *argsbuf[2]; |
81 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
82 | 0 | PyObject *input; |
83 | 0 | int final = 0; |
84 | |
|
85 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
86 | 0 | if (!args) { |
87 | 0 | goto exit; |
88 | 0 | } |
89 | 0 | input = args[0]; |
90 | 0 | if (!noptargs) { |
91 | 0 | goto skip_optional_pos; |
92 | 0 | } |
93 | 0 | if (PyFloat_Check(args[1])) { |
94 | 0 | PyErr_SetString(PyExc_TypeError, |
95 | 0 | "integer argument expected, got float" ); |
96 | 0 | goto exit; |
97 | 0 | } |
98 | 0 | final = _PyLong_AsInt(args[1]); |
99 | 0 | if (final == -1 && PyErr_Occurred()) { |
100 | 0 | goto exit; |
101 | 0 | } |
102 | 0 | skip_optional_pos: |
103 | 0 | return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final); |
104 | |
|
105 | 0 | exit: |
106 | 0 | return return_value; |
107 | 0 | } |
108 | | |
109 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__, |
110 | | "getstate($self, /)\n" |
111 | | "--\n" |
112 | | "\n"); |
113 | | |
114 | | #define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \ |
115 | | {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__}, |
116 | | |
117 | | static PyObject * |
118 | | _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self); |
119 | | |
120 | | static PyObject * |
121 | | _io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored)) |
122 | 0 | { |
123 | 0 | return _io_IncrementalNewlineDecoder_getstate_impl(self); |
124 | 0 | } |
125 | | |
126 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__, |
127 | | "setstate($self, state, /)\n" |
128 | | "--\n" |
129 | | "\n"); |
130 | | |
131 | | #define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \ |
132 | | {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__}, |
133 | | |
134 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__, |
135 | | "reset($self, /)\n" |
136 | | "--\n" |
137 | | "\n"); |
138 | | |
139 | | #define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \ |
140 | | {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__}, |
141 | | |
142 | | static PyObject * |
143 | | _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self); |
144 | | |
145 | | static PyObject * |
146 | | _io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored)) |
147 | 0 | { |
148 | 0 | return _io_IncrementalNewlineDecoder_reset_impl(self); |
149 | 0 | } |
150 | | |
151 | | PyDoc_STRVAR(_io_TextIOWrapper___init____doc__, |
152 | | "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n" |
153 | | " line_buffering=False, write_through=False)\n" |
154 | | "--\n" |
155 | | "\n" |
156 | | "Character and line based layer over a BufferedIOBase object, buffer.\n" |
157 | | "\n" |
158 | | "encoding gives the name of the encoding that the stream will be\n" |
159 | | "decoded or encoded with. It defaults to locale.getpreferredencoding(False).\n" |
160 | | "\n" |
161 | | "errors determines the strictness of encoding and decoding (see\n" |
162 | | "help(codecs.Codec) or the documentation for codecs.register) and\n" |
163 | | "defaults to \"strict\".\n" |
164 | | "\n" |
165 | | "newline controls how line endings are handled. It can be None, \'\',\n" |
166 | | "\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n" |
167 | | "\n" |
168 | | "* On input, if newline is None, universal newlines mode is\n" |
169 | | " enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n" |
170 | | " these are translated into \'\\n\' before being returned to the\n" |
171 | | " caller. If it is \'\', universal newline mode is enabled, but line\n" |
172 | | " endings are returned to the caller untranslated. If it has any of\n" |
173 | | " the other legal values, input lines are only terminated by the given\n" |
174 | | " string, and the line ending is returned to the caller untranslated.\n" |
175 | | "\n" |
176 | | "* On output, if newline is None, any \'\\n\' characters written are\n" |
177 | | " translated to the system default line separator, os.linesep. If\n" |
178 | | " newline is \'\' or \'\\n\', no translation takes place. If newline is any\n" |
179 | | " of the other legal values, any \'\\n\' characters written are translated\n" |
180 | | " to the given string.\n" |
181 | | "\n" |
182 | | "If line_buffering is True, a call to flush is implied when a call to\n" |
183 | | "write contains a newline character."); |
184 | | |
185 | | static int |
186 | | _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, |
187 | | const char *encoding, PyObject *errors, |
188 | | const char *newline, int line_buffering, |
189 | | int write_through); |
190 | | |
191 | | static int |
192 | | _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
193 | 43 | { |
194 | 43 | int return_value = -1; |
195 | 43 | static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
196 | 43 | static _PyArg_Parser _parser = {NULL, _keywords, "TextIOWrapper", 0}; |
197 | 43 | PyObject *argsbuf[6]; |
198 | 43 | PyObject * const *fastargs; |
199 | 43 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
200 | 43 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
201 | 43 | PyObject *buffer; |
202 | 43 | const char *encoding = NULL; |
203 | 43 | PyObject *errors = Py_None; |
204 | 43 | const char *newline = NULL; |
205 | 43 | int line_buffering = 0; |
206 | 43 | int write_through = 0; |
207 | | |
208 | 43 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf); |
209 | 43 | if (!fastargs) { |
210 | 0 | goto exit; |
211 | 0 | } |
212 | 43 | buffer = fastargs[0]; |
213 | 43 | if (!noptargs) { |
214 | 0 | goto skip_optional_pos; |
215 | 0 | } |
216 | 43 | if (fastargs[1]) { |
217 | 43 | if (fastargs[1] == Py_None) { |
218 | 0 | encoding = NULL; |
219 | 0 | } |
220 | 43 | else if (PyUnicode_Check(fastargs[1])) { |
221 | 43 | Py_ssize_t encoding_length; |
222 | 43 | encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); |
223 | 43 | if (encoding == NULL) { |
224 | 0 | goto exit; |
225 | 0 | } |
226 | 43 | if (strlen(encoding) != (size_t)encoding_length) { |
227 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
228 | 0 | goto exit; |
229 | 0 | } |
230 | 43 | } |
231 | 0 | else { |
232 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); |
233 | 0 | goto exit; |
234 | 0 | } |
235 | 43 | if (!--noptargs) { |
236 | 0 | goto skip_optional_pos; |
237 | 0 | } |
238 | 43 | } |
239 | 43 | if (fastargs[2]) { |
240 | 42 | errors = fastargs[2]; |
241 | 42 | if (!--noptargs) { |
242 | 0 | goto skip_optional_pos; |
243 | 0 | } |
244 | 42 | } |
245 | 43 | if (fastargs[3]) { |
246 | 42 | if (fastargs[3] == Py_None) { |
247 | 0 | newline = NULL; |
248 | 0 | } |
249 | 42 | else if (PyUnicode_Check(fastargs[3])) { |
250 | 42 | Py_ssize_t newline_length; |
251 | 42 | newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); |
252 | 42 | if (newline == NULL) { |
253 | 0 | goto exit; |
254 | 0 | } |
255 | 42 | if (strlen(newline) != (size_t)newline_length) { |
256 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
257 | 0 | goto exit; |
258 | 0 | } |
259 | 42 | } |
260 | 0 | else { |
261 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); |
262 | 0 | goto exit; |
263 | 0 | } |
264 | 42 | if (!--noptargs) { |
265 | 0 | goto skip_optional_pos; |
266 | 0 | } |
267 | 42 | } |
268 | 43 | if (fastargs[4]) { |
269 | 43 | if (PyFloat_Check(fastargs[4])) { |
270 | 0 | PyErr_SetString(PyExc_TypeError, |
271 | 0 | "integer argument expected, got float" ); |
272 | 0 | goto exit; |
273 | 0 | } |
274 | 43 | line_buffering = _PyLong_AsInt(fastargs[4]); |
275 | 43 | if (line_buffering == -1 && PyErr_Occurred()) { |
276 | 0 | goto exit; |
277 | 0 | } |
278 | 43 | if (!--noptargs) { |
279 | 1 | goto skip_optional_pos; |
280 | 1 | } |
281 | 43 | } |
282 | 42 | if (PyFloat_Check(fastargs[5])) { |
283 | 0 | PyErr_SetString(PyExc_TypeError, |
284 | 0 | "integer argument expected, got float" ); |
285 | 0 | goto exit; |
286 | 0 | } |
287 | 42 | write_through = _PyLong_AsInt(fastargs[5]); |
288 | 42 | if (write_through == -1 && PyErr_Occurred()) { |
289 | 0 | goto exit; |
290 | 0 | } |
291 | 43 | skip_optional_pos: |
292 | 43 | return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through); |
293 | | |
294 | 43 | exit: |
295 | 43 | return return_value; |
296 | 43 | } |
297 | | |
298 | | PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__, |
299 | | "reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n" |
300 | | " line_buffering=None, write_through=None)\n" |
301 | | "--\n" |
302 | | "\n" |
303 | | "Reconfigure the text stream with new parameters.\n" |
304 | | "\n" |
305 | | "This also does an implicit stream flush."); |
306 | | |
307 | | #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \ |
308 | | {"reconfigure", (PyCFunction)(void(*)(void))_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, |
309 | | |
310 | | static PyObject * |
311 | | _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, |
312 | | PyObject *errors, PyObject *newline_obj, |
313 | | PyObject *line_buffering_obj, |
314 | | PyObject *write_through_obj); |
315 | | |
316 | | static PyObject * |
317 | | _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
318 | 0 | { |
319 | 0 | PyObject *return_value = NULL; |
320 | 0 | static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
321 | 0 | static _PyArg_Parser _parser = {NULL, _keywords, "reconfigure", 0}; |
322 | 0 | PyObject *argsbuf[5]; |
323 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
324 | 0 | PyObject *encoding = Py_None; |
325 | 0 | PyObject *errors = Py_None; |
326 | 0 | PyObject *newline_obj = NULL; |
327 | 0 | PyObject *line_buffering_obj = Py_None; |
328 | 0 | PyObject *write_through_obj = Py_None; |
329 | |
|
330 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); |
331 | 0 | if (!args) { |
332 | 0 | goto exit; |
333 | 0 | } |
334 | 0 | if (!noptargs) { |
335 | 0 | goto skip_optional_kwonly; |
336 | 0 | } |
337 | 0 | if (args[0]) { |
338 | 0 | encoding = args[0]; |
339 | 0 | if (!--noptargs) { |
340 | 0 | goto skip_optional_kwonly; |
341 | 0 | } |
342 | 0 | } |
343 | 0 | if (args[1]) { |
344 | 0 | errors = args[1]; |
345 | 0 | if (!--noptargs) { |
346 | 0 | goto skip_optional_kwonly; |
347 | 0 | } |
348 | 0 | } |
349 | 0 | if (args[2]) { |
350 | 0 | newline_obj = args[2]; |
351 | 0 | if (!--noptargs) { |
352 | 0 | goto skip_optional_kwonly; |
353 | 0 | } |
354 | 0 | } |
355 | 0 | if (args[3]) { |
356 | 0 | line_buffering_obj = args[3]; |
357 | 0 | if (!--noptargs) { |
358 | 0 | goto skip_optional_kwonly; |
359 | 0 | } |
360 | 0 | } |
361 | 0 | write_through_obj = args[4]; |
362 | 0 | skip_optional_kwonly: |
363 | 0 | return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); |
364 | |
|
365 | 0 | exit: |
366 | 0 | return return_value; |
367 | 0 | } |
368 | | |
369 | | PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__, |
370 | | "detach($self, /)\n" |
371 | | "--\n" |
372 | | "\n"); |
373 | | |
374 | | #define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \ |
375 | | {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__}, |
376 | | |
377 | | static PyObject * |
378 | | _io_TextIOWrapper_detach_impl(textio *self); |
379 | | |
380 | | static PyObject * |
381 | | _io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored)) |
382 | 0 | { |
383 | 0 | return _io_TextIOWrapper_detach_impl(self); |
384 | 0 | } |
385 | | |
386 | | PyDoc_STRVAR(_io_TextIOWrapper_write__doc__, |
387 | | "write($self, text, /)\n" |
388 | | "--\n" |
389 | | "\n"); |
390 | | |
391 | | #define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \ |
392 | | {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__}, |
393 | | |
394 | | static PyObject * |
395 | | _io_TextIOWrapper_write_impl(textio *self, PyObject *text); |
396 | | |
397 | | static PyObject * |
398 | | _io_TextIOWrapper_write(textio *self, PyObject *arg) |
399 | 14 | { |
400 | 14 | PyObject *return_value = NULL; |
401 | 14 | PyObject *text; |
402 | | |
403 | 14 | if (!PyUnicode_Check(arg)) { |
404 | 0 | _PyArg_BadArgument("write", "argument", "str", arg); |
405 | 0 | goto exit; |
406 | 0 | } |
407 | 14 | if (PyUnicode_READY(arg) == -1) { |
408 | 0 | goto exit; |
409 | 0 | } |
410 | 14 | text = arg; |
411 | 14 | return_value = _io_TextIOWrapper_write_impl(self, text); |
412 | | |
413 | 14 | exit: |
414 | 14 | return return_value; |
415 | 14 | } |
416 | | |
417 | | PyDoc_STRVAR(_io_TextIOWrapper_read__doc__, |
418 | | "read($self, size=-1, /)\n" |
419 | | "--\n" |
420 | | "\n"); |
421 | | |
422 | | #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ |
423 | | {"read", (PyCFunction)(void(*)(void))_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__}, |
424 | | |
425 | | static PyObject * |
426 | | _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); |
427 | | |
428 | | static PyObject * |
429 | | _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs) |
430 | 0 | { |
431 | 0 | PyObject *return_value = NULL; |
432 | 0 | Py_ssize_t n = -1; |
433 | |
|
434 | 0 | if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
435 | 0 | goto exit; |
436 | 0 | } |
437 | 0 | if (nargs < 1) { |
438 | 0 | goto skip_optional; |
439 | 0 | } |
440 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { |
441 | 0 | goto exit; |
442 | 0 | } |
443 | 0 | skip_optional: |
444 | 0 | return_value = _io_TextIOWrapper_read_impl(self, n); |
445 | |
|
446 | 0 | exit: |
447 | 0 | return return_value; |
448 | 0 | } |
449 | | |
450 | | PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__, |
451 | | "readline($self, size=-1, /)\n" |
452 | | "--\n" |
453 | | "\n"); |
454 | | |
455 | | #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ |
456 | | {"readline", (PyCFunction)(void(*)(void))_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, |
457 | | |
458 | | static PyObject * |
459 | | _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); |
460 | | |
461 | | static PyObject * |
462 | | _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs) |
463 | 0 | { |
464 | 0 | PyObject *return_value = NULL; |
465 | 0 | Py_ssize_t size = -1; |
466 | |
|
467 | 0 | if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
468 | 0 | goto exit; |
469 | 0 | } |
470 | 0 | if (nargs < 1) { |
471 | 0 | goto skip_optional; |
472 | 0 | } |
473 | 0 | if (PyFloat_Check(args[0])) { |
474 | 0 | PyErr_SetString(PyExc_TypeError, |
475 | 0 | "integer argument expected, got float" ); |
476 | 0 | goto exit; |
477 | 0 | } |
478 | 0 | { |
479 | 0 | Py_ssize_t ival = -1; |
480 | 0 | PyObject *iobj = PyNumber_Index(args[0]); |
481 | 0 | if (iobj != NULL) { |
482 | 0 | ival = PyLong_AsSsize_t(iobj); |
483 | 0 | Py_DECREF(iobj); |
484 | 0 | } |
485 | 0 | if (ival == -1 && PyErr_Occurred()) { |
486 | 0 | goto exit; |
487 | 0 | } |
488 | 0 | size = ival; |
489 | 0 | } |
490 | 0 | skip_optional: |
491 | 0 | return_value = _io_TextIOWrapper_readline_impl(self, size); |
492 | |
|
493 | 0 | exit: |
494 | 0 | return return_value; |
495 | 0 | } |
496 | | |
497 | | PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, |
498 | | "seek($self, cookie, whence=0, /)\n" |
499 | | "--\n" |
500 | | "\n"); |
501 | | |
502 | | #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ |
503 | | {"seek", (PyCFunction)(void(*)(void))_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, |
504 | | |
505 | | static PyObject * |
506 | | _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); |
507 | | |
508 | | static PyObject * |
509 | | _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs) |
510 | 0 | { |
511 | 0 | PyObject *return_value = NULL; |
512 | 0 | PyObject *cookieObj; |
513 | 0 | int whence = 0; |
514 | |
|
515 | 0 | if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { |
516 | 0 | goto exit; |
517 | 0 | } |
518 | 0 | cookieObj = args[0]; |
519 | 0 | if (nargs < 2) { |
520 | 0 | goto skip_optional; |
521 | 0 | } |
522 | 0 | if (PyFloat_Check(args[1])) { |
523 | 0 | PyErr_SetString(PyExc_TypeError, |
524 | 0 | "integer argument expected, got float" ); |
525 | 0 | goto exit; |
526 | 0 | } |
527 | 0 | whence = _PyLong_AsInt(args[1]); |
528 | 0 | if (whence == -1 && PyErr_Occurred()) { |
529 | 0 | goto exit; |
530 | 0 | } |
531 | 0 | skip_optional: |
532 | 0 | return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); |
533 | |
|
534 | 0 | exit: |
535 | 0 | return return_value; |
536 | 0 | } |
537 | | |
538 | | PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__, |
539 | | "tell($self, /)\n" |
540 | | "--\n" |
541 | | "\n"); |
542 | | |
543 | | #define _IO_TEXTIOWRAPPER_TELL_METHODDEF \ |
544 | | {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__}, |
545 | | |
546 | | static PyObject * |
547 | | _io_TextIOWrapper_tell_impl(textio *self); |
548 | | |
549 | | static PyObject * |
550 | | _io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored)) |
551 | 0 | { |
552 | 0 | return _io_TextIOWrapper_tell_impl(self); |
553 | 0 | } |
554 | | |
555 | | PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, |
556 | | "truncate($self, pos=None, /)\n" |
557 | | "--\n" |
558 | | "\n"); |
559 | | |
560 | | #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ |
561 | | {"truncate", (PyCFunction)(void(*)(void))_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, |
562 | | |
563 | | static PyObject * |
564 | | _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); |
565 | | |
566 | | static PyObject * |
567 | | _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs) |
568 | 0 | { |
569 | 0 | PyObject *return_value = NULL; |
570 | 0 | PyObject *pos = Py_None; |
571 | |
|
572 | 0 | if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { |
573 | 0 | goto exit; |
574 | 0 | } |
575 | 0 | if (nargs < 1) { |
576 | 0 | goto skip_optional; |
577 | 0 | } |
578 | 0 | pos = args[0]; |
579 | 0 | skip_optional: |
580 | 0 | return_value = _io_TextIOWrapper_truncate_impl(self, pos); |
581 | |
|
582 | 0 | exit: |
583 | 0 | return return_value; |
584 | 0 | } |
585 | | |
586 | | PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__, |
587 | | "fileno($self, /)\n" |
588 | | "--\n" |
589 | | "\n"); |
590 | | |
591 | | #define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \ |
592 | | {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__}, |
593 | | |
594 | | static PyObject * |
595 | | _io_TextIOWrapper_fileno_impl(textio *self); |
596 | | |
597 | | static PyObject * |
598 | | _io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored)) |
599 | 0 | { |
600 | 0 | return _io_TextIOWrapper_fileno_impl(self); |
601 | 0 | } |
602 | | |
603 | | PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__, |
604 | | "seekable($self, /)\n" |
605 | | "--\n" |
606 | | "\n"); |
607 | | |
608 | | #define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \ |
609 | | {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__}, |
610 | | |
611 | | static PyObject * |
612 | | _io_TextIOWrapper_seekable_impl(textio *self); |
613 | | |
614 | | static PyObject * |
615 | | _io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored)) |
616 | 0 | { |
617 | 0 | return _io_TextIOWrapper_seekable_impl(self); |
618 | 0 | } |
619 | | |
620 | | PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__, |
621 | | "readable($self, /)\n" |
622 | | "--\n" |
623 | | "\n"); |
624 | | |
625 | | #define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \ |
626 | | {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__}, |
627 | | |
628 | | static PyObject * |
629 | | _io_TextIOWrapper_readable_impl(textio *self); |
630 | | |
631 | | static PyObject * |
632 | | _io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored)) |
633 | 0 | { |
634 | 0 | return _io_TextIOWrapper_readable_impl(self); |
635 | 0 | } |
636 | | |
637 | | PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__, |
638 | | "writable($self, /)\n" |
639 | | "--\n" |
640 | | "\n"); |
641 | | |
642 | | #define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \ |
643 | | {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__}, |
644 | | |
645 | | static PyObject * |
646 | | _io_TextIOWrapper_writable_impl(textio *self); |
647 | | |
648 | | static PyObject * |
649 | | _io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored)) |
650 | 0 | { |
651 | 0 | return _io_TextIOWrapper_writable_impl(self); |
652 | 0 | } |
653 | | |
654 | | PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__, |
655 | | "isatty($self, /)\n" |
656 | | "--\n" |
657 | | "\n"); |
658 | | |
659 | | #define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \ |
660 | | {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__}, |
661 | | |
662 | | static PyObject * |
663 | | _io_TextIOWrapper_isatty_impl(textio *self); |
664 | | |
665 | | static PyObject * |
666 | | _io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored)) |
667 | 0 | { |
668 | 0 | return _io_TextIOWrapper_isatty_impl(self); |
669 | 0 | } |
670 | | |
671 | | PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__, |
672 | | "flush($self, /)\n" |
673 | | "--\n" |
674 | | "\n"); |
675 | | |
676 | | #define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \ |
677 | | {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__}, |
678 | | |
679 | | static PyObject * |
680 | | _io_TextIOWrapper_flush_impl(textio *self); |
681 | | |
682 | | static PyObject * |
683 | | _io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored)) |
684 | 15 | { |
685 | 15 | return _io_TextIOWrapper_flush_impl(self); |
686 | 15 | } |
687 | | |
688 | | PyDoc_STRVAR(_io_TextIOWrapper_close__doc__, |
689 | | "close($self, /)\n" |
690 | | "--\n" |
691 | | "\n"); |
692 | | |
693 | | #define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \ |
694 | | {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__}, |
695 | | |
696 | | static PyObject * |
697 | | _io_TextIOWrapper_close_impl(textio *self); |
698 | | |
699 | | static PyObject * |
700 | | _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) |
701 | 1 | { |
702 | 1 | return _io_TextIOWrapper_close_impl(self); |
703 | 1 | } |
704 | | /*[clinic end generated code: output=b1bae4f4cdf6019e input=a9049054013a1b77]*/ |