Coverage Report

Created: 2026-02-26 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Modules/_io/clinic/textio.c.h
Line
Count
Source
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
16.1k
{
314
16.1k
    int return_value = -1;
315
16.1k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
316
317
16.1k
    #define NUM_KEYWORDS 3
318
16.1k
    static struct {
319
16.1k
        PyGC_Head _this_is_not_used;
320
16.1k
        PyObject_VAR_HEAD
321
16.1k
        Py_hash_t ob_hash;
322
16.1k
        PyObject *ob_item[NUM_KEYWORDS];
323
16.1k
    } _kwtuple = {
324
16.1k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
325
16.1k
        .ob_hash = -1,
326
16.1k
        .ob_item = { &_Py_ID(decoder), &_Py_ID(translate), &_Py_ID(errors), },
327
16.1k
    };
328
16.1k
    #undef NUM_KEYWORDS
329
16.1k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
330
331
    #else  // !Py_BUILD_CORE
332
    #  define KWTUPLE NULL
333
    #endif  // !Py_BUILD_CORE
334
335
16.1k
    static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
336
16.1k
    static _PyArg_Parser _parser = {
337
16.1k
        .keywords = _keywords,
338
16.1k
        .fname = "IncrementalNewlineDecoder",
339
16.1k
        .kwtuple = KWTUPLE,
340
16.1k
    };
341
16.1k
    #undef KWTUPLE
342
16.1k
    PyObject *argsbuf[3];
343
16.1k
    PyObject * const *fastargs;
344
16.1k
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
345
16.1k
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
346
16.1k
    PyObject *decoder;
347
16.1k
    int translate;
348
16.1k
    PyObject *errors = NULL;
349
350
16.1k
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
351
16.1k
            /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
352
16.1k
    if (!fastargs) {
353
0
        goto exit;
354
0
    }
355
16.1k
    decoder = fastargs[0];
356
16.1k
    translate = PyObject_IsTrue(fastargs[1]);
357
16.1k
    if (translate < 0) {
358
0
        goto exit;
359
0
    }
360
16.1k
    if (!noptargs) {
361
16.1k
        goto skip_optional_pos;
362
16.1k
    }
363
0
    errors = fastargs[2];
364
16.1k
skip_optional_pos:
365
16.1k
    return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
366
367
16.1k
exit:
368
16.1k
    return return_value;
369
16.1k
}
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
    Py_BEGIN_CRITICAL_SECTION(self);
434
0
    return_value = _io_IncrementalNewlineDecoder_decode_impl((nldecoder_object *)self, input, final);
435
0
    Py_END_CRITICAL_SECTION();
436
437
0
exit:
438
0
    return return_value;
439
0
}
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
0
{
455
0
    PyObject *return_value = NULL;
456
457
0
    Py_BEGIN_CRITICAL_SECTION(self);
458
0
    return_value = _io_IncrementalNewlineDecoder_getstate_impl((nldecoder_object *)self);
459
0
    Py_END_CRITICAL_SECTION();
460
461
0
    return return_value;
462
0
}
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
0
{
479
0
    PyObject *return_value = NULL;
480
481
0
    Py_BEGIN_CRITICAL_SECTION(self);
482
0
    return_value = _io_IncrementalNewlineDecoder_setstate_impl((nldecoder_object *)self, state);
483
0
    Py_END_CRITICAL_SECTION();
484
485
0
    return return_value;
486
0
}
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
0
{
502
0
    PyObject *return_value = NULL;
503
504
0
    Py_BEGIN_CRITICAL_SECTION(self);
505
0
    return_value = _io_IncrementalNewlineDecoder_reset_impl((nldecoder_object *)self);
506
0
    Py_END_CRITICAL_SECTION();
507
508
0
    return return_value;
509
0
}
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
104
{
554
104
    int return_value = -1;
555
104
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
556
557
104
    #define NUM_KEYWORDS 6
558
104
    static struct {
559
104
        PyGC_Head _this_is_not_used;
560
104
        PyObject_VAR_HEAD
561
104
        Py_hash_t ob_hash;
562
104
        PyObject *ob_item[NUM_KEYWORDS];
563
104
    } _kwtuple = {
564
104
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
565
104
        .ob_hash = -1,
566
104
        .ob_item = { &_Py_ID(buffer), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
567
104
    };
568
104
    #undef NUM_KEYWORDS
569
104
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
570
571
    #else  // !Py_BUILD_CORE
572
    #  define KWTUPLE NULL
573
    #endif  // !Py_BUILD_CORE
574
575
104
    static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
576
104
    static _PyArg_Parser _parser = {
577
104
        .keywords = _keywords,
578
104
        .fname = "TextIOWrapper",
579
104
        .kwtuple = KWTUPLE,
580
104
    };
581
104
    #undef KWTUPLE
582
104
    PyObject *argsbuf[6];
583
104
    PyObject * const *fastargs;
584
104
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
585
104
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
586
104
    PyObject *buffer;
587
104
    const char *encoding = NULL;
588
104
    PyObject *errors = Py_None;
589
104
    const char *newline = NULL;
590
104
    int line_buffering = 0;
591
104
    int write_through = 0;
592
593
104
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
594
104
            /*minpos*/ 1, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
595
104
    if (!fastargs) {
596
0
        goto exit;
597
0
    }
598
104
    buffer = fastargs[0];
599
104
    if (!noptargs) {
600
0
        goto skip_optional_pos;
601
0
    }
602
104
    if (fastargs[1]) {
603
104
        if (fastargs[1] == Py_None) {
604
0
            encoding = NULL;
605
0
        }
606
104
        else if (PyUnicode_Check(fastargs[1])) {
607
104
            Py_ssize_t encoding_length;
608
104
            encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
609
104
            if (encoding == NULL) {
610
0
                goto exit;
611
0
            }
612
104
            if (strlen(encoding) != (size_t)encoding_length) {
613
0
                PyErr_SetString(PyExc_ValueError, "embedded null character");
614
0
                goto exit;
615
0
            }
616
104
        }
617
0
        else {
618
0
            _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]);
619
0
            goto exit;
620
0
        }
621
104
        if (!--noptargs) {
622
0
            goto skip_optional_pos;
623
0
        }
624
104
    }
625
104
    if (fastargs[2]) {
626
100
        errors = fastargs[2];
627
100
        if (!--noptargs) {
628
0
            goto skip_optional_pos;
629
0
        }
630
100
    }
631
104
    if (fastargs[3]) {
632
100
        if (fastargs[3] == Py_None) {
633
4
            newline = NULL;
634
4
        }
635
96
        else if (PyUnicode_Check(fastargs[3])) {
636
96
            Py_ssize_t newline_length;
637
96
            newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length);
638
96
            if (newline == NULL) {
639
0
                goto exit;
640
0
            }
641
96
            if (strlen(newline) != (size_t)newline_length) {
642
0
                PyErr_SetString(PyExc_ValueError, "embedded null character");
643
0
                goto exit;
644
0
            }
645
96
        }
646
0
        else {
647
0
            _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]);
648
0
            goto exit;
649
0
        }
650
100
        if (!--noptargs) {
651
0
            goto skip_optional_pos;
652
0
        }
653
100
    }
654
104
    if (fastargs[4]) {
655
104
        line_buffering = PyObject_IsTrue(fastargs[4]);
656
104
        if (line_buffering < 0) {
657
0
            goto exit;
658
0
        }
659
104
        if (!--noptargs) {
660
8
            goto skip_optional_pos;
661
8
        }
662
104
    }
663
96
    write_through = PyObject_IsTrue(fastargs[5]);
664
96
    if (write_through < 0) {
665
0
        goto exit;
666
0
    }
667
104
skip_optional_pos:
668
104
    return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
669
670
104
exit:
671
104
    return return_value;
672
104
}
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
0
{
695
0
    PyObject *return_value = NULL;
696
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
697
698
0
    #define NUM_KEYWORDS 5
699
0
    static struct {
700
0
        PyGC_Head _this_is_not_used;
701
0
        PyObject_VAR_HEAD
702
0
        Py_hash_t ob_hash;
703
0
        PyObject *ob_item[NUM_KEYWORDS];
704
0
    } _kwtuple = {
705
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
706
0
        .ob_hash = -1,
707
0
        .ob_item = { &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
708
0
    };
709
0
    #undef NUM_KEYWORDS
710
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
711
712
    #else  // !Py_BUILD_CORE
713
    #  define KWTUPLE NULL
714
    #endif  // !Py_BUILD_CORE
715
716
0
    static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL};
717
0
    static _PyArg_Parser _parser = {
718
0
        .keywords = _keywords,
719
0
        .fname = "reconfigure",
720
0
        .kwtuple = KWTUPLE,
721
0
    };
722
0
    #undef KWTUPLE
723
0
    PyObject *argsbuf[5];
724
0
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
725
0
    PyObject *encoding = Py_None;
726
0
    PyObject *errors = Py_None;
727
0
    PyObject *newline_obj = NULL;
728
0
    PyObject *line_buffering_obj = Py_None;
729
0
    PyObject *write_through_obj = Py_None;
730
731
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
732
0
            /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
733
0
    if (!args) {
734
0
        goto exit;
735
0
    }
736
0
    if (!noptargs) {
737
0
        goto skip_optional_kwonly;
738
0
    }
739
0
    if (args[0]) {
740
0
        encoding = args[0];
741
0
        if (!--noptargs) {
742
0
            goto skip_optional_kwonly;
743
0
        }
744
0
    }
745
0
    if (args[1]) {
746
0
        errors = args[1];
747
0
        if (!--noptargs) {
748
0
            goto skip_optional_kwonly;
749
0
        }
750
0
    }
751
0
    if (args[2]) {
752
0
        newline_obj = args[2];
753
0
        if (!--noptargs) {
754
0
            goto skip_optional_kwonly;
755
0
        }
756
0
    }
757
0
    if (args[3]) {
758
0
        line_buffering_obj = args[3];
759
0
        if (!--noptargs) {
760
0
            goto skip_optional_kwonly;
761
0
        }
762
0
    }
763
0
    write_through_obj = args[4];
764
0
skip_optional_kwonly:
765
0
    Py_BEGIN_CRITICAL_SECTION(self);
766
0
    return_value = _io_TextIOWrapper_reconfigure_impl((textio *)self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj);
767
0
    Py_END_CRITICAL_SECTION();
768
769
0
exit:
770
0
    return return_value;
771
0
}
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
0
{
787
0
    PyObject *return_value = NULL;
788
789
0
    Py_BEGIN_CRITICAL_SECTION(self);
790
0
    return_value = _io_TextIOWrapper_detach_impl((textio *)self);
791
0
    Py_END_CRITICAL_SECTION();
792
793
0
    return return_value;
794
0
}
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
254k
{
810
254k
    PyObject *return_value = NULL;
811
254k
    PyObject *text;
812
813
254k
    if (!PyUnicode_Check(arg)) {
814
0
        _PyArg_BadArgument("write", "argument", "str", arg);
815
0
        goto exit;
816
0
    }
817
254k
    text = arg;
818
254k
    Py_BEGIN_CRITICAL_SECTION(self);
819
254k
    return_value = _io_TextIOWrapper_write_impl((textio *)self, text);
820
254k
    Py_END_CRITICAL_SECTION();
821
822
254k
exit:
823
254k
    return return_value;
824
254k
}
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
4
{
840
4
    PyObject *return_value = NULL;
841
4
    Py_ssize_t n = -1;
842
843
4
    if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
844
0
        goto exit;
845
0
    }
846
4
    if (nargs < 1) {
847
4
        goto skip_optional;
848
4
    }
849
0
    if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
850
0
        goto exit;
851
0
    }
852
4
skip_optional:
853
4
    Py_BEGIN_CRITICAL_SECTION(self);
854
4
    return_value = _io_TextIOWrapper_read_impl((textio *)self, n);
855
4
    Py_END_CRITICAL_SECTION();
856
857
4
exit:
858
4
    return return_value;
859
4
}
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
0
{
875
0
    PyObject *return_value = NULL;
876
0
    Py_ssize_t size = -1;
877
878
0
    if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
879
0
        goto exit;
880
0
    }
881
0
    if (nargs < 1) {
882
0
        goto skip_optional;
883
0
    }
884
0
    {
885
0
        Py_ssize_t ival = -1;
886
0
        PyObject *iobj = _PyNumber_Index(args[0]);
887
0
        if (iobj != NULL) {
888
0
            ival = PyLong_AsSsize_t(iobj);
889
0
            Py_DECREF(iobj);
890
0
        }
891
0
        if (ival == -1 && PyErr_Occurred()) {
892
0
            goto exit;
893
0
        }
894
0
        size = ival;
895
0
    }
896
0
skip_optional:
897
0
    Py_BEGIN_CRITICAL_SECTION(self);
898
0
    return_value = _io_TextIOWrapper_readline_impl((textio *)self, size);
899
0
    Py_END_CRITICAL_SECTION();
900
901
0
exit:
902
0
    return return_value;
903
0
}
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
0
{
937
0
    PyObject *return_value = NULL;
938
0
    PyObject *cookieObj;
939
0
    int whence = 0;
940
941
0
    if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
942
0
        goto exit;
943
0
    }
944
0
    cookieObj = args[0];
945
0
    if (nargs < 2) {
946
0
        goto skip_optional;
947
0
    }
948
0
    whence = PyLong_AsInt(args[1]);
949
0
    if (whence == -1 && PyErr_Occurred()) {
950
0
        goto exit;
951
0
    }
952
0
skip_optional:
953
0
    Py_BEGIN_CRITICAL_SECTION(self);
954
0
    return_value = _io_TextIOWrapper_seek_impl((textio *)self, cookieObj, whence);
955
0
    Py_END_CRITICAL_SECTION();
956
957
0
exit:
958
0
    return return_value;
959
0
}
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
0
{
979
0
    PyObject *return_value = NULL;
980
981
0
    Py_BEGIN_CRITICAL_SECTION(self);
982
0
    return_value = _io_TextIOWrapper_tell_impl((textio *)self);
983
0
    Py_END_CRITICAL_SECTION();
984
985
0
    return return_value;
986
0
}
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
0
{
1002
0
    PyObject *return_value = NULL;
1003
0
    PyObject *pos = Py_None;
1004
1005
0
    if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
1006
0
        goto exit;
1007
0
    }
1008
0
    if (nargs < 1) {
1009
0
        goto skip_optional;
1010
0
    }
1011
0
    pos = args[0];
1012
0
skip_optional:
1013
0
    Py_BEGIN_CRITICAL_SECTION(self);
1014
0
    return_value = _io_TextIOWrapper_truncate_impl((textio *)self, pos);
1015
0
    Py_END_CRITICAL_SECTION();
1016
1017
0
exit:
1018
0
    return return_value;
1019
0
}
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
0
{
1035
0
    PyObject *return_value = NULL;
1036
1037
0
    Py_BEGIN_CRITICAL_SECTION(self);
1038
0
    return_value = _io_TextIOWrapper_fileno_impl((textio *)self);
1039
0
    Py_END_CRITICAL_SECTION();
1040
1041
0
    return return_value;
1042
0
}
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
0
{
1058
0
    PyObject *return_value = NULL;
1059
1060
0
    Py_BEGIN_CRITICAL_SECTION(self);
1061
0
    return_value = _io_TextIOWrapper_seekable_impl((textio *)self);
1062
0
    Py_END_CRITICAL_SECTION();
1063
1064
0
    return return_value;
1065
0
}
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
0
{
1081
0
    PyObject *return_value = NULL;
1082
1083
0
    Py_BEGIN_CRITICAL_SECTION(self);
1084
0
    return_value = _io_TextIOWrapper_readable_impl((textio *)self);
1085
0
    Py_END_CRITICAL_SECTION();
1086
1087
0
    return return_value;
1088
0
}
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
0
{
1104
0
    PyObject *return_value = NULL;
1105
1106
0
    Py_BEGIN_CRITICAL_SECTION(self);
1107
0
    return_value = _io_TextIOWrapper_writable_impl((textio *)self);
1108
0
    Py_END_CRITICAL_SECTION();
1109
1110
0
    return return_value;
1111
0
}
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
0
{
1127
0
    PyObject *return_value = NULL;
1128
1129
0
    Py_BEGIN_CRITICAL_SECTION(self);
1130
0
    return_value = _io_TextIOWrapper_isatty_impl((textio *)self);
1131
0
    Py_END_CRITICAL_SECTION();
1132
1133
0
    return return_value;
1134
0
}
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
8
{
1150
8
    PyObject *return_value = NULL;
1151
1152
8
    Py_BEGIN_CRITICAL_SECTION(self);
1153
8
    return_value = _io_TextIOWrapper_flush_impl((textio *)self);
1154
8
    Py_END_CRITICAL_SECTION();
1155
1156
8
    return return_value;
1157
8
}
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
8
{
1173
8
    PyObject *return_value = NULL;
1174
1175
8
    Py_BEGIN_CRITICAL_SECTION(self);
1176
8
    return_value = _io_TextIOWrapper_close_impl((textio *)self);
1177
8
    Py_END_CRITICAL_SECTION();
1178
1179
8
    return return_value;
1180
8
}
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
0
{
1198
0
    PyObject *return_value = NULL;
1199
1200
0
    Py_BEGIN_CRITICAL_SECTION(self);
1201
0
    return_value = _io_TextIOWrapper_name_get_impl((textio *)self);
1202
0
    Py_END_CRITICAL_SECTION();
1203
1204
0
    return return_value;
1205
0
}
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
20
{
1223
20
    PyObject *return_value = NULL;
1224
1225
20
    Py_BEGIN_CRITICAL_SECTION(self);
1226
20
    return_value = _io_TextIOWrapper_closed_get_impl((textio *)self);
1227
20
    Py_END_CRITICAL_SECTION();
1228
1229
20
    return return_value;
1230
20
}
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
0
{
1248
0
    PyObject *return_value = NULL;
1249
1250
0
    Py_BEGIN_CRITICAL_SECTION(self);
1251
0
    return_value = _io_TextIOWrapper_newlines_get_impl((textio *)self);
1252
0
    Py_END_CRITICAL_SECTION();
1253
1254
0
    return return_value;
1255
0
}
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
0
{
1273
0
    PyObject *return_value = NULL;
1274
1275
0
    Py_BEGIN_CRITICAL_SECTION(self);
1276
0
    return_value = _io_TextIOWrapper_errors_get_impl((textio *)self);
1277
0
    Py_END_CRITICAL_SECTION();
1278
1279
0
    return return_value;
1280
0
}
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
0
{
1298
0
    PyObject *return_value = NULL;
1299
1300
0
    Py_BEGIN_CRITICAL_SECTION(self);
1301
0
    return_value = _io_TextIOWrapper__CHUNK_SIZE_get_impl((textio *)self);
1302
0
    Py_END_CRITICAL_SECTION();
1303
1304
0
    return return_value;
1305
0
}
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
0
{
1323
0
    int return_value;
1324
1325
0
    Py_BEGIN_CRITICAL_SECTION(self);
1326
0
    return_value = _io_TextIOWrapper__CHUNK_SIZE_set_impl((textio *)self, value);
1327
0
    Py_END_CRITICAL_SECTION();
1328
1329
0
    return return_value;
1330
0
}
1331
/*[clinic end generated code: output=c38e6cd5ff4b7eea input=a9049054013a1b77]*/