Coverage Report

Created: 2026-05-30 06:18

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