/src/cpython/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 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_SINGLETON() |
8 | | #endif |
9 | | #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() |
10 | | #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
11 | | #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
12 | | |
13 | | PyDoc_STRVAR(_io__TextIOBase_detach__doc__, |
14 | | "detach($self, /)\n" |
15 | | "--\n" |
16 | | "\n" |
17 | | "Separate the underlying buffer from the TextIOBase and return it.\n" |
18 | | "\n" |
19 | | "After the underlying buffer has been detached, the TextIO is in an unusable state."); |
20 | | |
21 | | #define _IO__TEXTIOBASE_DETACH_METHODDEF \ |
22 | | {"detach", _PyCFunction_CAST(_io__TextIOBase_detach), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_detach__doc__}, |
23 | | |
24 | | static PyObject * |
25 | | _io__TextIOBase_detach_impl(PyObject *self, PyTypeObject *cls); |
26 | | |
27 | | static PyObject * |
28 | | _io__TextIOBase_detach(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
29 | 0 | { |
30 | 0 | if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
31 | 0 | PyErr_SetString(PyExc_TypeError, "detach() takes no arguments"); |
32 | 0 | return NULL; |
33 | 0 | } |
34 | 0 | return _io__TextIOBase_detach_impl(self, cls); |
35 | 0 | } |
36 | | |
37 | | PyDoc_STRVAR(_io__TextIOBase_read__doc__, |
38 | | "read($self, size=-1, /)\n" |
39 | | "--\n" |
40 | | "\n" |
41 | | "Read at most size characters from stream.\n" |
42 | | "\n" |
43 | | "Read from underlying buffer until we have size characters or we hit EOF.\n" |
44 | | "If size is negative or omitted, read until EOF."); |
45 | | |
46 | | #define _IO__TEXTIOBASE_READ_METHODDEF \ |
47 | | {"read", _PyCFunction_CAST(_io__TextIOBase_read), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_read__doc__}, |
48 | | |
49 | | static PyObject * |
50 | | _io__TextIOBase_read_impl(PyObject *self, PyTypeObject *cls, |
51 | | int Py_UNUSED(size)); |
52 | | |
53 | | static PyObject * |
54 | | _io__TextIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
55 | 0 | { |
56 | 0 | PyObject *return_value = NULL; |
57 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
58 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
59 | | #else |
60 | | # define KWTUPLE NULL |
61 | | #endif |
62 | |
|
63 | 0 | static const char * const _keywords[] = {"", NULL}; |
64 | 0 | static _PyArg_Parser _parser = { |
65 | 0 | .keywords = _keywords, |
66 | 0 | .fname = "read", |
67 | 0 | .kwtuple = KWTUPLE, |
68 | 0 | }; |
69 | 0 | #undef KWTUPLE |
70 | 0 | PyObject *argsbuf[1]; |
71 | 0 | int size = -1; |
72 | |
|
73 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
74 | 0 | /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
75 | 0 | if (!args) { |
76 | 0 | goto exit; |
77 | 0 | } |
78 | 0 | if (nargs < 1) { |
79 | 0 | goto skip_optional_posonly; |
80 | 0 | } |
81 | 0 | size = PyLong_AsInt(args[0]); |
82 | 0 | if (size == -1 && PyErr_Occurred()) { |
83 | 0 | goto exit; |
84 | 0 | } |
85 | 0 | skip_optional_posonly: |
86 | 0 | return_value = _io__TextIOBase_read_impl(self, cls, size); |
87 | |
|
88 | 0 | exit: |
89 | 0 | return return_value; |
90 | 0 | } |
91 | | |
92 | | PyDoc_STRVAR(_io__TextIOBase_readline__doc__, |
93 | | "readline($self, size=-1, /)\n" |
94 | | "--\n" |
95 | | "\n" |
96 | | "Read until newline or EOF.\n" |
97 | | "\n" |
98 | | "Return an empty string if EOF is hit immediately.\n" |
99 | | "If size is specified, at most size characters will be read."); |
100 | | |
101 | | #define _IO__TEXTIOBASE_READLINE_METHODDEF \ |
102 | | {"readline", _PyCFunction_CAST(_io__TextIOBase_readline), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_readline__doc__}, |
103 | | |
104 | | static PyObject * |
105 | | _io__TextIOBase_readline_impl(PyObject *self, PyTypeObject *cls, |
106 | | int Py_UNUSED(size)); |
107 | | |
108 | | static PyObject * |
109 | | _io__TextIOBase_readline(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
110 | 0 | { |
111 | 0 | PyObject *return_value = NULL; |
112 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
113 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
114 | | #else |
115 | | # define KWTUPLE NULL |
116 | | #endif |
117 | |
|
118 | 0 | static const char * const _keywords[] = {"", NULL}; |
119 | 0 | static _PyArg_Parser _parser = { |
120 | 0 | .keywords = _keywords, |
121 | 0 | .fname = "readline", |
122 | 0 | .kwtuple = KWTUPLE, |
123 | 0 | }; |
124 | 0 | #undef KWTUPLE |
125 | 0 | PyObject *argsbuf[1]; |
126 | 0 | int size = -1; |
127 | |
|
128 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
129 | 0 | /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
130 | 0 | if (!args) { |
131 | 0 | goto exit; |
132 | 0 | } |
133 | 0 | if (nargs < 1) { |
134 | 0 | goto skip_optional_posonly; |
135 | 0 | } |
136 | 0 | size = PyLong_AsInt(args[0]); |
137 | 0 | if (size == -1 && PyErr_Occurred()) { |
138 | 0 | goto exit; |
139 | 0 | } |
140 | 0 | skip_optional_posonly: |
141 | 0 | return_value = _io__TextIOBase_readline_impl(self, cls, size); |
142 | |
|
143 | 0 | exit: |
144 | 0 | return return_value; |
145 | 0 | } |
146 | | |
147 | | PyDoc_STRVAR(_io__TextIOBase_write__doc__, |
148 | | "write($self, s, /)\n" |
149 | | "--\n" |
150 | | "\n" |
151 | | "Write string s to stream.\n" |
152 | | "\n" |
153 | | "Return the number of characters written\n" |
154 | | "(which is always equal to the length of the string)."); |
155 | | |
156 | | #define _IO__TEXTIOBASE_WRITE_METHODDEF \ |
157 | | {"write", _PyCFunction_CAST(_io__TextIOBase_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_write__doc__}, |
158 | | |
159 | | static PyObject * |
160 | | _io__TextIOBase_write_impl(PyObject *self, PyTypeObject *cls, |
161 | | const char *Py_UNUSED(s)); |
162 | | |
163 | | static PyObject * |
164 | | _io__TextIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
165 | 0 | { |
166 | 0 | PyObject *return_value = NULL; |
167 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
168 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
169 | | #else |
170 | | # define KWTUPLE NULL |
171 | | #endif |
172 | |
|
173 | 0 | static const char * const _keywords[] = {"", NULL}; |
174 | 0 | static _PyArg_Parser _parser = { |
175 | 0 | .keywords = _keywords, |
176 | 0 | .fname = "write", |
177 | 0 | .kwtuple = KWTUPLE, |
178 | 0 | }; |
179 | 0 | #undef KWTUPLE |
180 | 0 | PyObject *argsbuf[1]; |
181 | 0 | const char *s; |
182 | |
|
183 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
184 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
185 | 0 | if (!args) { |
186 | 0 | goto exit; |
187 | 0 | } |
188 | 0 | if (!PyUnicode_Check(args[0])) { |
189 | 0 | _PyArg_BadArgument("write", "argument 1", "str", args[0]); |
190 | 0 | goto exit; |
191 | 0 | } |
192 | 0 | Py_ssize_t s_length; |
193 | 0 | s = PyUnicode_AsUTF8AndSize(args[0], &s_length); |
194 | 0 | if (s == NULL) { |
195 | 0 | goto exit; |
196 | 0 | } |
197 | 0 | if (strlen(s) != (size_t)s_length) { |
198 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
199 | 0 | goto exit; |
200 | 0 | } |
201 | 0 | return_value = _io__TextIOBase_write_impl(self, cls, s); |
202 | |
|
203 | 0 | exit: |
204 | 0 | return return_value; |
205 | 0 | } |
206 | | |
207 | | PyDoc_STRVAR(_io__TextIOBase_encoding__doc__, |
208 | | "Encoding of the text stream.\n" |
209 | | "\n" |
210 | | "Subclasses should override."); |
211 | | #if defined(_io__TextIOBase_encoding_DOCSTR) |
212 | | # undef _io__TextIOBase_encoding_DOCSTR |
213 | | #endif |
214 | | #define _io__TextIOBase_encoding_DOCSTR _io__TextIOBase_encoding__doc__ |
215 | | |
216 | | #if !defined(_io__TextIOBase_encoding_DOCSTR) |
217 | | # define _io__TextIOBase_encoding_DOCSTR NULL |
218 | | #endif |
219 | | #if defined(_IO__TEXTIOBASE_ENCODING_GETSETDEF) |
220 | | # undef _IO__TEXTIOBASE_ENCODING_GETSETDEF |
221 | | # define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, (setter)_io__TextIOBase_encoding_set, _io__TextIOBase_encoding_DOCSTR}, |
222 | | #else |
223 | | # define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, NULL, _io__TextIOBase_encoding_DOCSTR}, |
224 | | #endif |
225 | | |
226 | | static PyObject * |
227 | | _io__TextIOBase_encoding_get_impl(PyObject *self); |
228 | | |
229 | | static PyObject * |
230 | | _io__TextIOBase_encoding_get(PyObject *self, void *Py_UNUSED(context)) |
231 | 0 | { |
232 | 0 | return _io__TextIOBase_encoding_get_impl(self); |
233 | 0 | } |
234 | | |
235 | | PyDoc_STRVAR(_io__TextIOBase_newlines__doc__, |
236 | | "Line endings translated so far.\n" |
237 | | "\n" |
238 | | "Only line endings translated during reading are considered.\n" |
239 | | "\n" |
240 | | "Subclasses should override."); |
241 | | #if defined(_io__TextIOBase_newlines_DOCSTR) |
242 | | # undef _io__TextIOBase_newlines_DOCSTR |
243 | | #endif |
244 | | #define _io__TextIOBase_newlines_DOCSTR _io__TextIOBase_newlines__doc__ |
245 | | |
246 | | #if !defined(_io__TextIOBase_newlines_DOCSTR) |
247 | | # define _io__TextIOBase_newlines_DOCSTR NULL |
248 | | #endif |
249 | | #if defined(_IO__TEXTIOBASE_NEWLINES_GETSETDEF) |
250 | | # undef _IO__TEXTIOBASE_NEWLINES_GETSETDEF |
251 | | # define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, (setter)_io__TextIOBase_newlines_set, _io__TextIOBase_newlines_DOCSTR}, |
252 | | #else |
253 | | # define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, NULL, _io__TextIOBase_newlines_DOCSTR}, |
254 | | #endif |
255 | | |
256 | | static PyObject * |
257 | | _io__TextIOBase_newlines_get_impl(PyObject *self); |
258 | | |
259 | | static PyObject * |
260 | | _io__TextIOBase_newlines_get(PyObject *self, void *Py_UNUSED(context)) |
261 | 0 | { |
262 | 0 | return _io__TextIOBase_newlines_get_impl(self); |
263 | 0 | } |
264 | | |
265 | | PyDoc_STRVAR(_io__TextIOBase_errors__doc__, |
266 | | "The error setting of the decoder or encoder.\n" |
267 | | "\n" |
268 | | "Subclasses should override."); |
269 | | #if defined(_io__TextIOBase_errors_DOCSTR) |
270 | | # undef _io__TextIOBase_errors_DOCSTR |
271 | | #endif |
272 | | #define _io__TextIOBase_errors_DOCSTR _io__TextIOBase_errors__doc__ |
273 | | |
274 | | #if !defined(_io__TextIOBase_errors_DOCSTR) |
275 | | # define _io__TextIOBase_errors_DOCSTR NULL |
276 | | #endif |
277 | | #if defined(_IO__TEXTIOBASE_ERRORS_GETSETDEF) |
278 | | # undef _IO__TEXTIOBASE_ERRORS_GETSETDEF |
279 | | # define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, (setter)_io__TextIOBase_errors_set, _io__TextIOBase_errors_DOCSTR}, |
280 | | #else |
281 | | # define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, NULL, _io__TextIOBase_errors_DOCSTR}, |
282 | | #endif |
283 | | |
284 | | static PyObject * |
285 | | _io__TextIOBase_errors_get_impl(PyObject *self); |
286 | | |
287 | | static PyObject * |
288 | | _io__TextIOBase_errors_get(PyObject *self, void *Py_UNUSED(context)) |
289 | 0 | { |
290 | 0 | return _io__TextIOBase_errors_get_impl(self); |
291 | 0 | } |
292 | | |
293 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__, |
294 | | "IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n" |
295 | | "--\n" |
296 | | "\n" |
297 | | "Codec used when reading a file in universal newlines mode.\n" |
298 | | "\n" |
299 | | "It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n" |
300 | | "It also records the types of newlines encountered. When used with\n" |
301 | | "translate=False, it ensures that the newline sequence is returned in\n" |
302 | | "one piece. When used with decoder=None, it expects unicode strings as\n" |
303 | | "decode input and translates newlines without first invoking an external\n" |
304 | | "decoder."); |
305 | | |
306 | | static int |
307 | | _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self, |
308 | | PyObject *decoder, int translate, |
309 | | PyObject *errors); |
310 | | |
311 | | static int |
312 | | _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
313 | 17.4k | { |
314 | 17.4k | int return_value = -1; |
315 | 17.4k | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
316 | | |
317 | 17.4k | #define NUM_KEYWORDS 3 |
318 | 17.4k | static struct { |
319 | 17.4k | PyGC_Head _this_is_not_used; |
320 | 17.4k | PyObject_VAR_HEAD |
321 | 17.4k | Py_hash_t ob_hash; |
322 | 17.4k | PyObject *ob_item[NUM_KEYWORDS]; |
323 | 17.4k | } _kwtuple = { |
324 | 17.4k | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
325 | 17.4k | .ob_hash = -1, |
326 | 17.4k | .ob_item = { &_Py_ID(decoder), &_Py_ID(translate), &_Py_ID(errors), }, |
327 | 17.4k | }; |
328 | 17.4k | #undef NUM_KEYWORDS |
329 | 17.4k | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
330 | | |
331 | | #else // !Py_BUILD_CORE |
332 | | # define KWTUPLE NULL |
333 | | #endif // !Py_BUILD_CORE |
334 | | |
335 | 17.4k | static const char * const _keywords[] = {"decoder", "translate", "errors", NULL}; |
336 | 17.4k | static _PyArg_Parser _parser = { |
337 | 17.4k | .keywords = _keywords, |
338 | 17.4k | .fname = "IncrementalNewlineDecoder", |
339 | 17.4k | .kwtuple = KWTUPLE, |
340 | 17.4k | }; |
341 | 17.4k | #undef KWTUPLE |
342 | 17.4k | PyObject *argsbuf[3]; |
343 | 17.4k | PyObject * const *fastargs; |
344 | 17.4k | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
345 | 17.4k | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; |
346 | 17.4k | PyObject *decoder; |
347 | 17.4k | int translate; |
348 | 17.4k | PyObject *errors = NULL; |
349 | | |
350 | 17.4k | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
351 | 17.4k | /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
352 | 17.4k | if (!fastargs) { |
353 | 0 | goto exit; |
354 | 0 | } |
355 | 17.4k | decoder = fastargs[0]; |
356 | 17.4k | translate = PyObject_IsTrue(fastargs[1]); |
357 | 17.4k | if (translate < 0) { |
358 | 0 | goto exit; |
359 | 0 | } |
360 | 17.4k | if (!noptargs) { |
361 | 17.4k | goto skip_optional_pos; |
362 | 17.4k | } |
363 | 0 | errors = fastargs[2]; |
364 | 17.4k | skip_optional_pos: |
365 | 17.4k | return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); |
366 | | |
367 | 17.4k | exit: |
368 | 17.4k | return return_value; |
369 | 17.4k | } |
370 | | |
371 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, |
372 | | "decode($self, /, input, final=False)\n" |
373 | | "--\n" |
374 | | "\n"); |
375 | | |
376 | | #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ |
377 | | {"decode", _PyCFunction_CAST(_io_IncrementalNewlineDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, |
378 | | |
379 | | static PyObject * |
380 | | _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, |
381 | | PyObject *input, int final); |
382 | | |
383 | | static PyObject * |
384 | | _io_IncrementalNewlineDecoder_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
385 | 0 | { |
386 | 0 | PyObject *return_value = NULL; |
387 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
388 | |
|
389 | 0 | #define NUM_KEYWORDS 2 |
390 | 0 | static struct { |
391 | 0 | PyGC_Head _this_is_not_used; |
392 | 0 | PyObject_VAR_HEAD |
393 | 0 | Py_hash_t ob_hash; |
394 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
395 | 0 | } _kwtuple = { |
396 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
397 | 0 | .ob_hash = -1, |
398 | 0 | .ob_item = { &_Py_ID(input), &_Py_ID(final), }, |
399 | 0 | }; |
400 | 0 | #undef NUM_KEYWORDS |
401 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
402 | |
|
403 | | #else // !Py_BUILD_CORE |
404 | | # define KWTUPLE NULL |
405 | | #endif // !Py_BUILD_CORE |
406 | |
|
407 | 0 | static const char * const _keywords[] = {"input", "final", NULL}; |
408 | 0 | static _PyArg_Parser _parser = { |
409 | 0 | .keywords = _keywords, |
410 | 0 | .fname = "decode", |
411 | 0 | .kwtuple = KWTUPLE, |
412 | 0 | }; |
413 | 0 | #undef KWTUPLE |
414 | 0 | PyObject *argsbuf[2]; |
415 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
416 | 0 | PyObject *input; |
417 | 0 | int final = 0; |
418 | |
|
419 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
420 | 0 | /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
421 | 0 | if (!args) { |
422 | 0 | goto exit; |
423 | 0 | } |
424 | 0 | input = args[0]; |
425 | 0 | if (!noptargs) { |
426 | 0 | goto skip_optional_pos; |
427 | 0 | } |
428 | 0 | final = PyObject_IsTrue(args[1]); |
429 | 0 | if (final < 0) { |
430 | 0 | goto exit; |
431 | 0 | } |
432 | 0 | skip_optional_pos: |
433 | 0 | return_value = _io_IncrementalNewlineDecoder_decode_impl((nldecoder_object *)self, input, final); |
434 | |
|
435 | 0 | exit: |
436 | 0 | return return_value; |
437 | 0 | } |
438 | | |
439 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__, |
440 | | "getstate($self, /)\n" |
441 | | "--\n" |
442 | | "\n"); |
443 | | |
444 | | #define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \ |
445 | | {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__}, |
446 | | |
447 | | static PyObject * |
448 | | _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self); |
449 | | |
450 | | static PyObject * |
451 | | _io_IncrementalNewlineDecoder_getstate(PyObject *self, PyObject *Py_UNUSED(ignored)) |
452 | 0 | { |
453 | 0 | return _io_IncrementalNewlineDecoder_getstate_impl((nldecoder_object *)self); |
454 | 0 | } |
455 | | |
456 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__, |
457 | | "setstate($self, state, /)\n" |
458 | | "--\n" |
459 | | "\n"); |
460 | | |
461 | | #define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \ |
462 | | {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__}, |
463 | | |
464 | | static PyObject * |
465 | | _io_IncrementalNewlineDecoder_setstate_impl(nldecoder_object *self, |
466 | | PyObject *state); |
467 | | |
468 | | static PyObject * |
469 | | _io_IncrementalNewlineDecoder_setstate(PyObject *self, PyObject *state) |
470 | 0 | { |
471 | 0 | PyObject *return_value = NULL; |
472 | |
|
473 | 0 | return_value = _io_IncrementalNewlineDecoder_setstate_impl((nldecoder_object *)self, state); |
474 | |
|
475 | 0 | return return_value; |
476 | 0 | } |
477 | | |
478 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__, |
479 | | "reset($self, /)\n" |
480 | | "--\n" |
481 | | "\n"); |
482 | | |
483 | | #define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \ |
484 | | {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__}, |
485 | | |
486 | | static PyObject * |
487 | | _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self); |
488 | | |
489 | | static PyObject * |
490 | | _io_IncrementalNewlineDecoder_reset(PyObject *self, PyObject *Py_UNUSED(ignored)) |
491 | 0 | { |
492 | 0 | return _io_IncrementalNewlineDecoder_reset_impl((nldecoder_object *)self); |
493 | 0 | } |
494 | | |
495 | | PyDoc_STRVAR(_io_TextIOWrapper___init____doc__, |
496 | | "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n" |
497 | | " line_buffering=False, write_through=False)\n" |
498 | | "--\n" |
499 | | "\n" |
500 | | "Character and line based layer over a BufferedIOBase object, buffer.\n" |
501 | | "\n" |
502 | | "encoding gives the name of the encoding that the stream will be\n" |
503 | | "decoded or encoded with. It defaults to locale.getencoding().\n" |
504 | | "\n" |
505 | | "errors determines the strictness of encoding and decoding (see\n" |
506 | | "help(codecs.Codec) or the documentation for codecs.register) and\n" |
507 | | "defaults to \"strict\".\n" |
508 | | "\n" |
509 | | "newline controls how line endings are handled. It can be None, \'\',\n" |
510 | | "\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n" |
511 | | "\n" |
512 | | "* On input, if newline is None, universal newlines mode is\n" |
513 | | " enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n" |
514 | | " these are translated into \'\\n\' before being returned to the\n" |
515 | | " caller. If it is \'\', universal newline mode is enabled, but line\n" |
516 | | " endings are returned to the caller untranslated. If it has any of\n" |
517 | | " the other legal values, input lines are only terminated by the given\n" |
518 | | " string, and the line ending is returned to the caller untranslated.\n" |
519 | | "\n" |
520 | | "* On output, if newline is None, any \'\\n\' characters written are\n" |
521 | | " translated to the system default line separator, os.linesep. If\n" |
522 | | " newline is \'\' or \'\\n\', no translation takes place. If newline is any\n" |
523 | | " of the other legal values, any \'\\n\' characters written are translated\n" |
524 | | " to the given string.\n" |
525 | | "\n" |
526 | | "If line_buffering is True, a call to flush is implied when a call to\n" |
527 | | "write contains a newline character."); |
528 | | |
529 | | static int |
530 | | _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, |
531 | | const char *encoding, PyObject *errors, |
532 | | const char *newline, int line_buffering, |
533 | | int write_through); |
534 | | |
535 | | static int |
536 | | _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
537 | 48 | { |
538 | 48 | int return_value = -1; |
539 | 48 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
540 | | |
541 | 48 | #define NUM_KEYWORDS 6 |
542 | 48 | static struct { |
543 | 48 | PyGC_Head _this_is_not_used; |
544 | 48 | PyObject_VAR_HEAD |
545 | 48 | Py_hash_t ob_hash; |
546 | 48 | PyObject *ob_item[NUM_KEYWORDS]; |
547 | 48 | } _kwtuple = { |
548 | 48 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
549 | 48 | .ob_hash = -1, |
550 | 48 | .ob_item = { &_Py_ID(buffer), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), }, |
551 | 48 | }; |
552 | 48 | #undef NUM_KEYWORDS |
553 | 48 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
554 | | |
555 | | #else // !Py_BUILD_CORE |
556 | | # define KWTUPLE NULL |
557 | | #endif // !Py_BUILD_CORE |
558 | | |
559 | 48 | static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
560 | 48 | static _PyArg_Parser _parser = { |
561 | 48 | .keywords = _keywords, |
562 | 48 | .fname = "TextIOWrapper", |
563 | 48 | .kwtuple = KWTUPLE, |
564 | 48 | }; |
565 | 48 | #undef KWTUPLE |
566 | 48 | PyObject *argsbuf[6]; |
567 | 48 | PyObject * const *fastargs; |
568 | 48 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
569 | 48 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
570 | 48 | PyObject *buffer; |
571 | 48 | const char *encoding = NULL; |
572 | 48 | PyObject *errors = Py_None; |
573 | 48 | const char *newline = NULL; |
574 | 48 | int line_buffering = 0; |
575 | 48 | int write_through = 0; |
576 | | |
577 | 48 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
578 | 48 | /*minpos*/ 1, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
579 | 48 | if (!fastargs) { |
580 | 0 | goto exit; |
581 | 0 | } |
582 | 48 | buffer = fastargs[0]; |
583 | 48 | if (!noptargs) { |
584 | 0 | goto skip_optional_pos; |
585 | 0 | } |
586 | 48 | if (fastargs[1]) { |
587 | 48 | if (fastargs[1] == Py_None) { |
588 | 0 | encoding = NULL; |
589 | 0 | } |
590 | 48 | else if (PyUnicode_Check(fastargs[1])) { |
591 | 48 | Py_ssize_t encoding_length; |
592 | 48 | encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); |
593 | 48 | if (encoding == NULL) { |
594 | 0 | goto exit; |
595 | 0 | } |
596 | 48 | if (strlen(encoding) != (size_t)encoding_length) { |
597 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
598 | 0 | goto exit; |
599 | 0 | } |
600 | 48 | } |
601 | 0 | else { |
602 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); |
603 | 0 | goto exit; |
604 | 0 | } |
605 | 48 | if (!--noptargs) { |
606 | 0 | goto skip_optional_pos; |
607 | 0 | } |
608 | 48 | } |
609 | 48 | if (fastargs[2]) { |
610 | 48 | errors = fastargs[2]; |
611 | 48 | if (!--noptargs) { |
612 | 0 | goto skip_optional_pos; |
613 | 0 | } |
614 | 48 | } |
615 | 48 | if (fastargs[3]) { |
616 | 48 | if (fastargs[3] == Py_None) { |
617 | 0 | newline = NULL; |
618 | 0 | } |
619 | 48 | else if (PyUnicode_Check(fastargs[3])) { |
620 | 48 | Py_ssize_t newline_length; |
621 | 48 | newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); |
622 | 48 | if (newline == NULL) { |
623 | 0 | goto exit; |
624 | 0 | } |
625 | 48 | if (strlen(newline) != (size_t)newline_length) { |
626 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
627 | 0 | goto exit; |
628 | 0 | } |
629 | 48 | } |
630 | 0 | else { |
631 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); |
632 | 0 | goto exit; |
633 | 0 | } |
634 | 48 | if (!--noptargs) { |
635 | 0 | goto skip_optional_pos; |
636 | 0 | } |
637 | 48 | } |
638 | 48 | if (fastargs[4]) { |
639 | 48 | line_buffering = PyObject_IsTrue(fastargs[4]); |
640 | 48 | if (line_buffering < 0) { |
641 | 0 | goto exit; |
642 | 0 | } |
643 | 48 | if (!--noptargs) { |
644 | 0 | goto skip_optional_pos; |
645 | 0 | } |
646 | 48 | } |
647 | 48 | write_through = PyObject_IsTrue(fastargs[5]); |
648 | 48 | if (write_through < 0) { |
649 | 0 | goto exit; |
650 | 0 | } |
651 | 48 | skip_optional_pos: |
652 | 48 | return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through); |
653 | | |
654 | 48 | exit: |
655 | 48 | return return_value; |
656 | 48 | } |
657 | | |
658 | | PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__, |
659 | | "reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n" |
660 | | " line_buffering=None, write_through=None)\n" |
661 | | "--\n" |
662 | | "\n" |
663 | | "Reconfigure the text stream with new parameters.\n" |
664 | | "\n" |
665 | | "This also does an implicit stream flush."); |
666 | | |
667 | | #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \ |
668 | | {"reconfigure", _PyCFunction_CAST(_io_TextIOWrapper_reconfigure), METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, |
669 | | |
670 | | static PyObject * |
671 | | _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, |
672 | | PyObject *errors, PyObject *newline_obj, |
673 | | PyObject *line_buffering_obj, |
674 | | PyObject *write_through_obj); |
675 | | |
676 | | static PyObject * |
677 | | _io_TextIOWrapper_reconfigure(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
678 | 0 | { |
679 | 0 | PyObject *return_value = NULL; |
680 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
681 | |
|
682 | 0 | #define NUM_KEYWORDS 5 |
683 | 0 | static struct { |
684 | 0 | PyGC_Head _this_is_not_used; |
685 | 0 | PyObject_VAR_HEAD |
686 | 0 | Py_hash_t ob_hash; |
687 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
688 | 0 | } _kwtuple = { |
689 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
690 | 0 | .ob_hash = -1, |
691 | 0 | .ob_item = { &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), }, |
692 | 0 | }; |
693 | 0 | #undef NUM_KEYWORDS |
694 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
695 | |
|
696 | | #else // !Py_BUILD_CORE |
697 | | # define KWTUPLE NULL |
698 | | #endif // !Py_BUILD_CORE |
699 | |
|
700 | 0 | static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
701 | 0 | static _PyArg_Parser _parser = { |
702 | 0 | .keywords = _keywords, |
703 | 0 | .fname = "reconfigure", |
704 | 0 | .kwtuple = KWTUPLE, |
705 | 0 | }; |
706 | 0 | #undef KWTUPLE |
707 | 0 | PyObject *argsbuf[5]; |
708 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
709 | 0 | PyObject *encoding = Py_None; |
710 | 0 | PyObject *errors = Py_None; |
711 | 0 | PyObject *newline_obj = NULL; |
712 | 0 | PyObject *line_buffering_obj = Py_None; |
713 | 0 | PyObject *write_through_obj = Py_None; |
714 | |
|
715 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
716 | 0 | /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
717 | 0 | if (!args) { |
718 | 0 | goto exit; |
719 | 0 | } |
720 | 0 | if (!noptargs) { |
721 | 0 | goto skip_optional_kwonly; |
722 | 0 | } |
723 | 0 | if (args[0]) { |
724 | 0 | encoding = args[0]; |
725 | 0 | if (!--noptargs) { |
726 | 0 | goto skip_optional_kwonly; |
727 | 0 | } |
728 | 0 | } |
729 | 0 | if (args[1]) { |
730 | 0 | errors = args[1]; |
731 | 0 | if (!--noptargs) { |
732 | 0 | goto skip_optional_kwonly; |
733 | 0 | } |
734 | 0 | } |
735 | 0 | if (args[2]) { |
736 | 0 | newline_obj = args[2]; |
737 | 0 | if (!--noptargs) { |
738 | 0 | goto skip_optional_kwonly; |
739 | 0 | } |
740 | 0 | } |
741 | 0 | if (args[3]) { |
742 | 0 | line_buffering_obj = args[3]; |
743 | 0 | if (!--noptargs) { |
744 | 0 | goto skip_optional_kwonly; |
745 | 0 | } |
746 | 0 | } |
747 | 0 | write_through_obj = args[4]; |
748 | 0 | skip_optional_kwonly: |
749 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
750 | 0 | return_value = _io_TextIOWrapper_reconfigure_impl((textio *)self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); |
751 | 0 | Py_END_CRITICAL_SECTION(); |
752 | |
|
753 | 0 | exit: |
754 | 0 | return return_value; |
755 | 0 | } |
756 | | |
757 | | PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__, |
758 | | "detach($self, /)\n" |
759 | | "--\n" |
760 | | "\n"); |
761 | | |
762 | | #define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \ |
763 | | {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__}, |
764 | | |
765 | | static PyObject * |
766 | | _io_TextIOWrapper_detach_impl(textio *self); |
767 | | |
768 | | static PyObject * |
769 | | _io_TextIOWrapper_detach(PyObject *self, PyObject *Py_UNUSED(ignored)) |
770 | 0 | { |
771 | 0 | PyObject *return_value = NULL; |
772 | |
|
773 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
774 | 0 | return_value = _io_TextIOWrapper_detach_impl((textio *)self); |
775 | 0 | Py_END_CRITICAL_SECTION(); |
776 | |
|
777 | 0 | return return_value; |
778 | 0 | } |
779 | | |
780 | | PyDoc_STRVAR(_io_TextIOWrapper_write__doc__, |
781 | | "write($self, text, /)\n" |
782 | | "--\n" |
783 | | "\n"); |
784 | | |
785 | | #define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \ |
786 | | {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__}, |
787 | | |
788 | | static PyObject * |
789 | | _io_TextIOWrapper_write_impl(textio *self, PyObject *text); |
790 | | |
791 | | static PyObject * |
792 | | _io_TextIOWrapper_write(PyObject *self, PyObject *arg) |
793 | 0 | { |
794 | 0 | PyObject *return_value = NULL; |
795 | 0 | PyObject *text; |
796 | |
|
797 | 0 | if (!PyUnicode_Check(arg)) { |
798 | 0 | _PyArg_BadArgument("write", "argument", "str", arg); |
799 | 0 | goto exit; |
800 | 0 | } |
801 | 0 | text = arg; |
802 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
803 | 0 | return_value = _io_TextIOWrapper_write_impl((textio *)self, text); |
804 | 0 | Py_END_CRITICAL_SECTION(); |
805 | |
|
806 | 0 | exit: |
807 | 0 | return return_value; |
808 | 0 | } |
809 | | |
810 | | PyDoc_STRVAR(_io_TextIOWrapper_read__doc__, |
811 | | "read($self, size=-1, /)\n" |
812 | | "--\n" |
813 | | "\n"); |
814 | | |
815 | | #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ |
816 | | {"read", _PyCFunction_CAST(_io_TextIOWrapper_read), METH_FASTCALL, _io_TextIOWrapper_read__doc__}, |
817 | | |
818 | | static PyObject * |
819 | | _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); |
820 | | |
821 | | static PyObject * |
822 | | _io_TextIOWrapper_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
823 | 0 | { |
824 | 0 | PyObject *return_value = NULL; |
825 | 0 | Py_ssize_t n = -1; |
826 | |
|
827 | 0 | if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
828 | 0 | goto exit; |
829 | 0 | } |
830 | 0 | if (nargs < 1) { |
831 | 0 | goto skip_optional; |
832 | 0 | } |
833 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { |
834 | 0 | goto exit; |
835 | 0 | } |
836 | 0 | skip_optional: |
837 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
838 | 0 | return_value = _io_TextIOWrapper_read_impl((textio *)self, n); |
839 | 0 | Py_END_CRITICAL_SECTION(); |
840 | |
|
841 | 0 | exit: |
842 | 0 | return return_value; |
843 | 0 | } |
844 | | |
845 | | PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__, |
846 | | "readline($self, size=-1, /)\n" |
847 | | "--\n" |
848 | | "\n"); |
849 | | |
850 | | #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ |
851 | | {"readline", _PyCFunction_CAST(_io_TextIOWrapper_readline), METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, |
852 | | |
853 | | static PyObject * |
854 | | _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); |
855 | | |
856 | | static PyObject * |
857 | | _io_TextIOWrapper_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
858 | 0 | { |
859 | 0 | PyObject *return_value = NULL; |
860 | 0 | Py_ssize_t size = -1; |
861 | |
|
862 | 0 | if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
863 | 0 | goto exit; |
864 | 0 | } |
865 | 0 | if (nargs < 1) { |
866 | 0 | goto skip_optional; |
867 | 0 | } |
868 | 0 | { |
869 | 0 | Py_ssize_t ival = -1; |
870 | 0 | PyObject *iobj = _PyNumber_Index(args[0]); |
871 | 0 | if (iobj != NULL) { |
872 | 0 | ival = PyLong_AsSsize_t(iobj); |
873 | 0 | Py_DECREF(iobj); |
874 | 0 | } |
875 | 0 | if (ival == -1 && PyErr_Occurred()) { |
876 | 0 | goto exit; |
877 | 0 | } |
878 | 0 | size = ival; |
879 | 0 | } |
880 | 0 | skip_optional: |
881 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
882 | 0 | return_value = _io_TextIOWrapper_readline_impl((textio *)self, size); |
883 | 0 | Py_END_CRITICAL_SECTION(); |
884 | |
|
885 | 0 | exit: |
886 | 0 | return return_value; |
887 | 0 | } |
888 | | |
889 | | PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, |
890 | | "seek($self, cookie, whence=os.SEEK_SET, /)\n" |
891 | | "--\n" |
892 | | "\n" |
893 | | "Set the stream position, and return the new stream position.\n" |
894 | | "\n" |
895 | | " cookie\n" |
896 | | " Zero or an opaque number returned by tell().\n" |
897 | | " whence\n" |
898 | | " The relative position to seek from.\n" |
899 | | "\n" |
900 | | "Four operations are supported, given by the following argument\n" |
901 | | "combinations:\n" |
902 | | "\n" |
903 | | "- seek(0, SEEK_SET): Rewind to the start of the stream.\n" |
904 | | "- seek(cookie, SEEK_SET): Restore a previous position;\n" |
905 | | " \'cookie\' must be a number returned by tell().\n" |
906 | | "- seek(0, SEEK_END): Fast-forward to the end of the stream.\n" |
907 | | "- seek(0, SEEK_CUR): Leave the current stream position unchanged.\n" |
908 | | "\n" |
909 | | "Any other argument combinations are invalid,\n" |
910 | | "and may raise exceptions."); |
911 | | |
912 | | #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ |
913 | | {"seek", _PyCFunction_CAST(_io_TextIOWrapper_seek), METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, |
914 | | |
915 | | static PyObject * |
916 | | _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); |
917 | | |
918 | | static PyObject * |
919 | | _io_TextIOWrapper_seek(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
920 | 0 | { |
921 | 0 | PyObject *return_value = NULL; |
922 | 0 | PyObject *cookieObj; |
923 | 0 | int whence = 0; |
924 | |
|
925 | 0 | if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { |
926 | 0 | goto exit; |
927 | 0 | } |
928 | 0 | cookieObj = args[0]; |
929 | 0 | if (nargs < 2) { |
930 | 0 | goto skip_optional; |
931 | 0 | } |
932 | 0 | whence = PyLong_AsInt(args[1]); |
933 | 0 | if (whence == -1 && PyErr_Occurred()) { |
934 | 0 | goto exit; |
935 | 0 | } |
936 | 0 | skip_optional: |
937 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
938 | 0 | return_value = _io_TextIOWrapper_seek_impl((textio *)self, cookieObj, whence); |
939 | 0 | Py_END_CRITICAL_SECTION(); |
940 | |
|
941 | 0 | exit: |
942 | 0 | return return_value; |
943 | 0 | } |
944 | | |
945 | | PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__, |
946 | | "tell($self, /)\n" |
947 | | "--\n" |
948 | | "\n" |
949 | | "Return the stream position as an opaque number.\n" |
950 | | "\n" |
951 | | "The return value of tell() can be given as input to seek(), to restore a\n" |
952 | | "previous stream position."); |
953 | | |
954 | | #define _IO_TEXTIOWRAPPER_TELL_METHODDEF \ |
955 | | {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__}, |
956 | | |
957 | | static PyObject * |
958 | | _io_TextIOWrapper_tell_impl(textio *self); |
959 | | |
960 | | static PyObject * |
961 | | _io_TextIOWrapper_tell(PyObject *self, PyObject *Py_UNUSED(ignored)) |
962 | 0 | { |
963 | 0 | PyObject *return_value = NULL; |
964 | |
|
965 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
966 | 0 | return_value = _io_TextIOWrapper_tell_impl((textio *)self); |
967 | 0 | Py_END_CRITICAL_SECTION(); |
968 | |
|
969 | 0 | return return_value; |
970 | 0 | } |
971 | | |
972 | | PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, |
973 | | "truncate($self, pos=None, /)\n" |
974 | | "--\n" |
975 | | "\n"); |
976 | | |
977 | | #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ |
978 | | {"truncate", _PyCFunction_CAST(_io_TextIOWrapper_truncate), METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, |
979 | | |
980 | | static PyObject * |
981 | | _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); |
982 | | |
983 | | static PyObject * |
984 | | _io_TextIOWrapper_truncate(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
985 | 0 | { |
986 | 0 | PyObject *return_value = NULL; |
987 | 0 | PyObject *pos = Py_None; |
988 | |
|
989 | 0 | if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { |
990 | 0 | goto exit; |
991 | 0 | } |
992 | 0 | if (nargs < 1) { |
993 | 0 | goto skip_optional; |
994 | 0 | } |
995 | 0 | pos = args[0]; |
996 | 0 | skip_optional: |
997 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
998 | 0 | return_value = _io_TextIOWrapper_truncate_impl((textio *)self, pos); |
999 | 0 | Py_END_CRITICAL_SECTION(); |
1000 | |
|
1001 | 0 | exit: |
1002 | 0 | return return_value; |
1003 | 0 | } |
1004 | | |
1005 | | PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__, |
1006 | | "fileno($self, /)\n" |
1007 | | "--\n" |
1008 | | "\n"); |
1009 | | |
1010 | | #define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \ |
1011 | | {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__}, |
1012 | | |
1013 | | static PyObject * |
1014 | | _io_TextIOWrapper_fileno_impl(textio *self); |
1015 | | |
1016 | | static PyObject * |
1017 | | _io_TextIOWrapper_fileno(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1018 | 0 | { |
1019 | 0 | PyObject *return_value = NULL; |
1020 | |
|
1021 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1022 | 0 | return_value = _io_TextIOWrapper_fileno_impl((textio *)self); |
1023 | 0 | Py_END_CRITICAL_SECTION(); |
1024 | |
|
1025 | 0 | return return_value; |
1026 | 0 | } |
1027 | | |
1028 | | PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__, |
1029 | | "seekable($self, /)\n" |
1030 | | "--\n" |
1031 | | "\n"); |
1032 | | |
1033 | | #define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \ |
1034 | | {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__}, |
1035 | | |
1036 | | static PyObject * |
1037 | | _io_TextIOWrapper_seekable_impl(textio *self); |
1038 | | |
1039 | | static PyObject * |
1040 | | _io_TextIOWrapper_seekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1041 | 0 | { |
1042 | 0 | PyObject *return_value = NULL; |
1043 | |
|
1044 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1045 | 0 | return_value = _io_TextIOWrapper_seekable_impl((textio *)self); |
1046 | 0 | Py_END_CRITICAL_SECTION(); |
1047 | |
|
1048 | 0 | return return_value; |
1049 | 0 | } |
1050 | | |
1051 | | PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__, |
1052 | | "readable($self, /)\n" |
1053 | | "--\n" |
1054 | | "\n"); |
1055 | | |
1056 | | #define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \ |
1057 | | {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__}, |
1058 | | |
1059 | | static PyObject * |
1060 | | _io_TextIOWrapper_readable_impl(textio *self); |
1061 | | |
1062 | | static PyObject * |
1063 | | _io_TextIOWrapper_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1064 | 0 | { |
1065 | 0 | PyObject *return_value = NULL; |
1066 | |
|
1067 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1068 | 0 | return_value = _io_TextIOWrapper_readable_impl((textio *)self); |
1069 | 0 | Py_END_CRITICAL_SECTION(); |
1070 | |
|
1071 | 0 | return return_value; |
1072 | 0 | } |
1073 | | |
1074 | | PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__, |
1075 | | "writable($self, /)\n" |
1076 | | "--\n" |
1077 | | "\n"); |
1078 | | |
1079 | | #define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \ |
1080 | | {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__}, |
1081 | | |
1082 | | static PyObject * |
1083 | | _io_TextIOWrapper_writable_impl(textio *self); |
1084 | | |
1085 | | static PyObject * |
1086 | | _io_TextIOWrapper_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1087 | 0 | { |
1088 | 0 | PyObject *return_value = NULL; |
1089 | |
|
1090 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1091 | 0 | return_value = _io_TextIOWrapper_writable_impl((textio *)self); |
1092 | 0 | Py_END_CRITICAL_SECTION(); |
1093 | |
|
1094 | 0 | return return_value; |
1095 | 0 | } |
1096 | | |
1097 | | PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__, |
1098 | | "isatty($self, /)\n" |
1099 | | "--\n" |
1100 | | "\n"); |
1101 | | |
1102 | | #define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \ |
1103 | | {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__}, |
1104 | | |
1105 | | static PyObject * |
1106 | | _io_TextIOWrapper_isatty_impl(textio *self); |
1107 | | |
1108 | | static PyObject * |
1109 | | _io_TextIOWrapper_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1110 | 0 | { |
1111 | 0 | PyObject *return_value = NULL; |
1112 | |
|
1113 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1114 | 0 | return_value = _io_TextIOWrapper_isatty_impl((textio *)self); |
1115 | 0 | Py_END_CRITICAL_SECTION(); |
1116 | |
|
1117 | 0 | return return_value; |
1118 | 0 | } |
1119 | | |
1120 | | PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__, |
1121 | | "flush($self, /)\n" |
1122 | | "--\n" |
1123 | | "\n"); |
1124 | | |
1125 | | #define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \ |
1126 | | {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__}, |
1127 | | |
1128 | | static PyObject * |
1129 | | _io_TextIOWrapper_flush_impl(textio *self); |
1130 | | |
1131 | | static PyObject * |
1132 | | _io_TextIOWrapper_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1133 | 0 | { |
1134 | 0 | PyObject *return_value = NULL; |
1135 | |
|
1136 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1137 | 0 | return_value = _io_TextIOWrapper_flush_impl((textio *)self); |
1138 | 0 | Py_END_CRITICAL_SECTION(); |
1139 | |
|
1140 | 0 | return return_value; |
1141 | 0 | } |
1142 | | |
1143 | | PyDoc_STRVAR(_io_TextIOWrapper_close__doc__, |
1144 | | "close($self, /)\n" |
1145 | | "--\n" |
1146 | | "\n"); |
1147 | | |
1148 | | #define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \ |
1149 | | {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__}, |
1150 | | |
1151 | | static PyObject * |
1152 | | _io_TextIOWrapper_close_impl(textio *self); |
1153 | | |
1154 | | static PyObject * |
1155 | | _io_TextIOWrapper_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1156 | 0 | { |
1157 | 0 | PyObject *return_value = NULL; |
1158 | |
|
1159 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1160 | 0 | return_value = _io_TextIOWrapper_close_impl((textio *)self); |
1161 | 0 | Py_END_CRITICAL_SECTION(); |
1162 | |
|
1163 | 0 | return return_value; |
1164 | 0 | } |
1165 | | |
1166 | | #if !defined(_io_TextIOWrapper_name_DOCSTR) |
1167 | | # define _io_TextIOWrapper_name_DOCSTR NULL |
1168 | | #endif |
1169 | | #if defined(_IO_TEXTIOWRAPPER_NAME_GETSETDEF) |
1170 | | # undef _IO_TEXTIOWRAPPER_NAME_GETSETDEF |
1171 | | # define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, (setter)_io_TextIOWrapper_name_set, _io_TextIOWrapper_name_DOCSTR}, |
1172 | | #else |
1173 | | # define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, NULL, _io_TextIOWrapper_name_DOCSTR}, |
1174 | | #endif |
1175 | | |
1176 | | static PyObject * |
1177 | | _io_TextIOWrapper_name_get_impl(textio *self); |
1178 | | |
1179 | | static PyObject * |
1180 | | _io_TextIOWrapper_name_get(PyObject *self, void *Py_UNUSED(context)) |
1181 | 0 | { |
1182 | 0 | PyObject *return_value = NULL; |
1183 | |
|
1184 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1185 | 0 | return_value = _io_TextIOWrapper_name_get_impl((textio *)self); |
1186 | 0 | Py_END_CRITICAL_SECTION(); |
1187 | |
|
1188 | 0 | return return_value; |
1189 | 0 | } |
1190 | | |
1191 | | #if !defined(_io_TextIOWrapper_closed_DOCSTR) |
1192 | | # define _io_TextIOWrapper_closed_DOCSTR NULL |
1193 | | #endif |
1194 | | #if defined(_IO_TEXTIOWRAPPER_CLOSED_GETSETDEF) |
1195 | | # undef _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF |
1196 | | # define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, (setter)_io_TextIOWrapper_closed_set, _io_TextIOWrapper_closed_DOCSTR}, |
1197 | | #else |
1198 | | # define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, NULL, _io_TextIOWrapper_closed_DOCSTR}, |
1199 | | #endif |
1200 | | |
1201 | | static PyObject * |
1202 | | _io_TextIOWrapper_closed_get_impl(textio *self); |
1203 | | |
1204 | | static PyObject * |
1205 | | _io_TextIOWrapper_closed_get(PyObject *self, void *Py_UNUSED(context)) |
1206 | 0 | { |
1207 | 0 | PyObject *return_value = NULL; |
1208 | |
|
1209 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1210 | 0 | return_value = _io_TextIOWrapper_closed_get_impl((textio *)self); |
1211 | 0 | Py_END_CRITICAL_SECTION(); |
1212 | |
|
1213 | 0 | return return_value; |
1214 | 0 | } |
1215 | | |
1216 | | #if !defined(_io_TextIOWrapper_newlines_DOCSTR) |
1217 | | # define _io_TextIOWrapper_newlines_DOCSTR NULL |
1218 | | #endif |
1219 | | #if defined(_IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF) |
1220 | | # undef _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF |
1221 | | # define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, (setter)_io_TextIOWrapper_newlines_set, _io_TextIOWrapper_newlines_DOCSTR}, |
1222 | | #else |
1223 | | # define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, NULL, _io_TextIOWrapper_newlines_DOCSTR}, |
1224 | | #endif |
1225 | | |
1226 | | static PyObject * |
1227 | | _io_TextIOWrapper_newlines_get_impl(textio *self); |
1228 | | |
1229 | | static PyObject * |
1230 | | _io_TextIOWrapper_newlines_get(PyObject *self, void *Py_UNUSED(context)) |
1231 | 0 | { |
1232 | 0 | PyObject *return_value = NULL; |
1233 | |
|
1234 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1235 | 0 | return_value = _io_TextIOWrapper_newlines_get_impl((textio *)self); |
1236 | 0 | Py_END_CRITICAL_SECTION(); |
1237 | |
|
1238 | 0 | return return_value; |
1239 | 0 | } |
1240 | | |
1241 | | #if !defined(_io_TextIOWrapper_errors_DOCSTR) |
1242 | | # define _io_TextIOWrapper_errors_DOCSTR NULL |
1243 | | #endif |
1244 | | #if defined(_IO_TEXTIOWRAPPER_ERRORS_GETSETDEF) |
1245 | | # undef _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF |
1246 | | # define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, (setter)_io_TextIOWrapper_errors_set, _io_TextIOWrapper_errors_DOCSTR}, |
1247 | | #else |
1248 | | # define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, NULL, _io_TextIOWrapper_errors_DOCSTR}, |
1249 | | #endif |
1250 | | |
1251 | | static PyObject * |
1252 | | _io_TextIOWrapper_errors_get_impl(textio *self); |
1253 | | |
1254 | | static PyObject * |
1255 | | _io_TextIOWrapper_errors_get(PyObject *self, void *Py_UNUSED(context)) |
1256 | 0 | { |
1257 | 0 | PyObject *return_value = NULL; |
1258 | |
|
1259 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1260 | 0 | return_value = _io_TextIOWrapper_errors_get_impl((textio *)self); |
1261 | 0 | Py_END_CRITICAL_SECTION(); |
1262 | |
|
1263 | 0 | return return_value; |
1264 | 0 | } |
1265 | | |
1266 | | #if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) |
1267 | | # define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL |
1268 | | #endif |
1269 | | #if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) |
1270 | | # undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF |
1271 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1272 | | #else |
1273 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, NULL, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1274 | | #endif |
1275 | | |
1276 | | static PyObject * |
1277 | | _io_TextIOWrapper__CHUNK_SIZE_get_impl(textio *self); |
1278 | | |
1279 | | static PyObject * |
1280 | | _io_TextIOWrapper__CHUNK_SIZE_get(PyObject *self, void *Py_UNUSED(context)) |
1281 | 0 | { |
1282 | 0 | PyObject *return_value = NULL; |
1283 | |
|
1284 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1285 | 0 | return_value = _io_TextIOWrapper__CHUNK_SIZE_get_impl((textio *)self); |
1286 | 0 | Py_END_CRITICAL_SECTION(); |
1287 | |
|
1288 | 0 | return return_value; |
1289 | 0 | } |
1290 | | |
1291 | | #if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) |
1292 | | # define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL |
1293 | | #endif |
1294 | | #if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) |
1295 | | # undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF |
1296 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1297 | | #else |
1298 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", NULL, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, NULL}, |
1299 | | #endif |
1300 | | |
1301 | | static int |
1302 | | _io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value); |
1303 | | |
1304 | | static int |
1305 | | _io_TextIOWrapper__CHUNK_SIZE_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) |
1306 | 0 | { |
1307 | 0 | int return_value; |
1308 | |
|
1309 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1310 | 0 | return_value = _io_TextIOWrapper__CHUNK_SIZE_set_impl((textio *)self, value); |
1311 | 0 | Py_END_CRITICAL_SECTION(); |
1312 | |
|
1313 | 0 | return return_value; |
1314 | 0 | } |
1315 | | /*[clinic end generated code: output=30404271a1151056 input=a9049054013a1b77]*/ |