Debian Codegraph @

Modules/_io/clinic/textio.c.h

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