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