Coverage Report

Created: 2026-10-17 06:15

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