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/fileio.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_modsupport.h"    // _PyArg_UnpackKeywords()
11
#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL()
12
13
PyDoc_STRVAR(_io_FileIO__dealloc_warn__doc__,
14
"_dealloc_warn($self, source, /)\n"
15
"--\n"
16
"\n");
17
18
#define _IO_FILEIO__DEALLOC_WARN_METHODDEF    \
19
    {"_dealloc_warn", (PyCFunction)_io_FileIO__dealloc_warn, METH_O, _io_FileIO__dealloc_warn__doc__},
20
21
static PyObject *
22
_io_FileIO__dealloc_warn_impl(fileio *self, PyObject *source);
23
24
static PyObject *
25
_io_FileIO__dealloc_warn(PyObject *self, PyObject *source)
26
0
{
27
0
    PyObject *return_value = NULL;
28
29
0
    return_value = _io_FileIO__dealloc_warn_impl((fileio *)self, source);
30
31
0
    return return_value;
32
0
}
33
34
PyDoc_STRVAR(_io_FileIO_close__doc__,
35
"close($self, /)\n"
36
"--\n"
37
"\n"
38
"Close the file.\n"
39
"\n"
40
"A closed file cannot be used for further I/O operations.  close()\n"
41
"may be called more than once without error.");
42
43
#define _IO_FILEIO_CLOSE_METHODDEF    \
44
    {"close", _PyCFunction_CAST(_io_FileIO_close), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_close__doc__},
45
46
static PyObject *
47
_io_FileIO_close_impl(fileio *self, PyTypeObject *cls);
48
49
static PyObject *
50
_io_FileIO_close(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
51
24.5k
{
52
24.5k
    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
53
0
        PyErr_SetString(PyExc_TypeError, "close() takes no arguments");
54
0
        return NULL;
55
0
    }
56
24.5k
    return _io_FileIO_close_impl((fileio *)self, cls);
57
24.5k
}
58
59
PyDoc_STRVAR(_io_FileIO___init____doc__,
60
"FileIO(file, mode=\'r\', closefd=True, opener=None)\n"
61
"--\n"
62
"\n"
63
"Open a file.\n"
64
"\n"
65
"The mode can be \'r\' (default), \'w\', \'x\' or \'a\' for reading,\n"
66
"writing, exclusive creation or appending.  The file will be created\n"
67
"if it doesn\'t exist when opened for writing or appending; it will be\n"
68
"truncated when opened for writing.  A FileExistsError will be raised\n"
69
"if it already exists when opened for creating.  Opening a file for\n"
70
"creating implies writing so this mode behaves in a similar way to\n"
71
"\'w\'.  Add a \'+\' to the mode to allow simultaneous reading and\n"
72
"writing.\n"
73
"\n"
74
"A custom opener can be used by passing a callable as *opener*.\n"
75
"The underlying file descriptor for the file object is then obtained\n"
76
"by calling opener with (*name*, *flags*).  *opener* must return\n"
77
"an open file descriptor (passing os.open as *opener* results in\n"
78
"functionality similar to passing None).");
79
80
static int
81
_io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
82
                         int closefd, PyObject *opener);
83
84
static int
85
_io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
86
24.7k
{
87
24.7k
    int return_value = -1;
88
24.7k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
89
90
24.7k
    #define NUM_KEYWORDS 4
91
24.7k
    static struct {
92
24.7k
        PyGC_Head _this_is_not_used;
93
24.7k
        PyObject_VAR_HEAD
94
24.7k
        Py_hash_t ob_hash;
95
24.7k
        PyObject *ob_item[NUM_KEYWORDS];
96
24.7k
    } _kwtuple = {
97
24.7k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
98
24.7k
        .ob_hash = -1,
99
24.7k
        .ob_item = { &_Py_ID(file), &_Py_ID(mode), &_Py_ID(closefd), &_Py_ID(opener), },
100
24.7k
    };
101
24.7k
    #undef NUM_KEYWORDS
102
24.7k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
103
104
    #else  // !Py_BUILD_CORE
105
    #  define KWTUPLE NULL
106
    #endif  // !Py_BUILD_CORE
107
108
24.7k
    static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
109
24.7k
    static _PyArg_Parser _parser = {
110
24.7k
        .keywords = _keywords,
111
24.7k
        .fname = "FileIO",
112
24.7k
        .kwtuple = KWTUPLE,
113
24.7k
    };
114
24.7k
    #undef KWTUPLE
115
24.7k
    PyObject *argsbuf[4];
116
24.7k
    PyObject * const *fastargs;
117
24.7k
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
118
24.7k
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
119
24.7k
    PyObject *nameobj;
120
24.7k
    const char *mode = "r";
121
24.7k
    int closefd = 1;
122
24.7k
    PyObject *opener = Py_None;
123
124
24.7k
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
125
24.7k
            /*minpos*/ 1, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
126
24.7k
    if (!fastargs) {
127
0
        goto exit;
128
0
    }
129
24.7k
    nameobj = fastargs[0];
130
24.7k
    if (!noptargs) {
131
0
        goto skip_optional_pos;
132
0
    }
133
24.7k
    if (fastargs[1]) {
134
24.7k
        if (!PyUnicode_Check(fastargs[1])) {
135
0
            _PyArg_BadArgument("FileIO", "argument 'mode'", "str", fastargs[1]);
136
0
            goto exit;
137
0
        }
138
24.7k
        mode = _PyUnicode_AsUTF8NoNUL(fastargs[1]);
139
24.7k
        if (mode == NULL) {
140
0
            goto exit;
141
0
        }
142
24.7k
        if (!--noptargs) {
143
0
            goto skip_optional_pos;
144
0
        }
145
24.7k
    }
146
24.7k
    if (fastargs[2]) {
147
24.7k
        closefd = PyObject_IsTrue(fastargs[2]);
148
24.7k
        if (closefd < 0) {
149
0
            goto exit;
150
0
        }
151
24.7k
        if (!--noptargs) {
152
0
            goto skip_optional_pos;
153
0
        }
154
24.7k
    }
155
24.7k
    opener = fastargs[3];
156
24.7k
skip_optional_pos:
157
24.7k
    return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener);
158
159
24.7k
exit:
160
24.7k
    return return_value;
161
24.7k
}
162
163
PyDoc_STRVAR(_io_FileIO_fileno__doc__,
164
"fileno($self, /)\n"
165
"--\n"
166
"\n"
167
"Return the underlying file descriptor (an integer).");
168
169
#define _IO_FILEIO_FILENO_METHODDEF    \
170
    {"fileno", (PyCFunction)_io_FileIO_fileno, METH_NOARGS, _io_FileIO_fileno__doc__},
171
172
static PyObject *
173
_io_FileIO_fileno_impl(fileio *self);
174
175
static PyObject *
176
_io_FileIO_fileno(PyObject *self, PyObject *Py_UNUSED(ignored))
177
0
{
178
0
    return _io_FileIO_fileno_impl((fileio *)self);
179
0
}
180
181
PyDoc_STRVAR(_io_FileIO_readable__doc__,
182
"readable($self, /)\n"
183
"--\n"
184
"\n"
185
"True if file was opened in a read mode.");
186
187
#define _IO_FILEIO_READABLE_METHODDEF    \
188
    {"readable", (PyCFunction)_io_FileIO_readable, METH_NOARGS, _io_FileIO_readable__doc__},
189
190
static PyObject *
191
_io_FileIO_readable_impl(fileio *self);
192
193
static PyObject *
194
_io_FileIO_readable(PyObject *self, PyObject *Py_UNUSED(ignored))
195
5.88k
{
196
5.88k
    return _io_FileIO_readable_impl((fileio *)self);
197
5.88k
}
198
199
PyDoc_STRVAR(_io_FileIO_writable__doc__,
200
"writable($self, /)\n"
201
"--\n"
202
"\n"
203
"True if file was opened in a write mode.");
204
205
#define _IO_FILEIO_WRITABLE_METHODDEF    \
206
    {"writable", (PyCFunction)_io_FileIO_writable, METH_NOARGS, _io_FileIO_writable__doc__},
207
208
static PyObject *
209
_io_FileIO_writable_impl(fileio *self);
210
211
static PyObject *
212
_io_FileIO_writable(PyObject *self, PyObject *Py_UNUSED(ignored))
213
18.9k
{
214
18.9k
    return _io_FileIO_writable_impl((fileio *)self);
215
18.9k
}
216
217
PyDoc_STRVAR(_io_FileIO_seekable__doc__,
218
"seekable($self, /)\n"
219
"--\n"
220
"\n"
221
"True if file supports random-access.");
222
223
#define _IO_FILEIO_SEEKABLE_METHODDEF    \
224
    {"seekable", (PyCFunction)_io_FileIO_seekable, METH_NOARGS, _io_FileIO_seekable__doc__},
225
226
static PyObject *
227
_io_FileIO_seekable_impl(fileio *self);
228
229
static PyObject *
230
_io_FileIO_seekable(PyObject *self, PyObject *Py_UNUSED(ignored))
231
140
{
232
140
    return _io_FileIO_seekable_impl((fileio *)self);
233
140
}
234
235
PyDoc_STRVAR(_io_FileIO_readinto__doc__,
236
"readinto($self, buffer, /)\n"
237
"--\n"
238
"\n"
239
"Same as RawIOBase.readinto().");
240
241
#define _IO_FILEIO_READINTO_METHODDEF    \
242
    {"readinto", _PyCFunction_CAST(_io_FileIO_readinto), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_readinto__doc__},
243
244
static PyObject *
245
_io_FileIO_readinto_impl(fileio *self, PyTypeObject *cls, Py_buffer *buffer);
246
247
static PyObject *
248
_io_FileIO_readinto(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
249
44
{
250
44
    PyObject *return_value = NULL;
251
44
    Py_buffer buffer = {NULL, NULL};
252
253
44
    if (!_PyArg_NoKwnames("readinto", kwnames)) {
254
0
        goto exit;
255
0
    }
256
44
    if (!_PyArg_CheckPositional("readinto", nargs, 1, 1)) {
257
0
        goto exit;
258
0
    }
259
44
    if (PyObject_GetBuffer(args[0], &buffer, PyBUF_WRITABLE) < 0) {
260
0
        _PyArg_BadArgument("readinto", "argument 1", "read-write bytes-like object", args[0]);
261
0
        goto exit;
262
0
    }
263
44
    return_value = _io_FileIO_readinto_impl((fileio *)self, cls, &buffer);
264
265
44
exit:
266
    /* Cleanup for buffer */
267
44
    if (buffer.obj) {
268
44
       PyBuffer_Release(&buffer);
269
44
    }
270
271
44
    return return_value;
272
44
}
273
274
PyDoc_STRVAR(_io_FileIO_readall__doc__,
275
"readall($self, /)\n"
276
"--\n"
277
"\n"
278
"Read all data from the file, returned as bytes.\n"
279
"\n"
280
"Reads until either there is an error or read() returns size 0\n"
281
"(indicates EOF).  If the file is already at EOF, returns an empty\n"
282
"bytes object.\n"
283
"\n"
284
"In non-blocking mode, returns as much data as could be read before\n"
285
"EAGAIN.  If no data is available (EAGAIN is returned before bytes\n"
286
"are read) returns None.");
287
288
#define _IO_FILEIO_READALL_METHODDEF    \
289
    {"readall", _PyCFunction_CAST(_io_FileIO_readall), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_readall__doc__},
290
291
static PyObject *
292
_io_FileIO_readall_impl(fileio *self, PyTypeObject *cls);
293
294
static PyObject *
295
_io_FileIO_readall(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
296
5.77k
{
297
5.77k
    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
298
0
        PyErr_SetString(PyExc_TypeError, "readall() takes no arguments");
299
0
        return NULL;
300
0
    }
301
5.77k
    return _io_FileIO_readall_impl((fileio *)self, cls);
302
5.77k
}
303
304
PyDoc_STRVAR(_io_FileIO_read__doc__,
305
"read($self, size=-1, /)\n"
306
"--\n"
307
"\n"
308
"Read at most size bytes, returned as bytes.\n"
309
"\n"
310
"If size is less than 0, read all bytes in the file making multiple\n"
311
"read calls.  See ``FileIO.readall``.\n"
312
"\n"
313
"Attempts to make only one system call, retrying only per PEP 475\n"
314
"(EINTR).  This means less data may be returned than requested.\n"
315
"\n"
316
"In non-blocking mode, returns None if no data is available.  Return\n"
317
"an empty bytes object at EOF.");
318
319
#define _IO_FILEIO_READ_METHODDEF    \
320
    {"read", _PyCFunction_CAST(_io_FileIO_read), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_read__doc__},
321
322
static PyObject *
323
_io_FileIO_read_impl(fileio *self, PyTypeObject *cls, Py_ssize_t size);
324
325
static PyObject *
326
_io_FileIO_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
327
0
{
328
0
    PyObject *return_value = NULL;
329
0
    Py_ssize_t size = -1;
330
331
0
    if (!_PyArg_NoKwnames("read", kwnames)) {
332
0
        goto exit;
333
0
    }
334
0
    if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
335
0
        goto exit;
336
0
    }
337
0
    if (nargs < 1) {
338
0
        goto skip_optional;
339
0
    }
340
0
    if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
341
0
        goto exit;
342
0
    }
343
0
skip_optional:
344
0
    return_value = _io_FileIO_read_impl((fileio *)self, cls, size);
345
346
0
exit:
347
0
    return return_value;
348
0
}
349
350
PyDoc_STRVAR(_io_FileIO_write__doc__,
351
"write($self, b, /)\n"
352
"--\n"
353
"\n"
354
"Write buffer b to file, return number of bytes written.\n"
355
"\n"
356
"Only makes one system call, so not all of the data may be written.\n"
357
"The number of bytes actually written is returned.  In non-blocking\n"
358
"mode, returns None if the write would block.");
359
360
#define _IO_FILEIO_WRITE_METHODDEF    \
361
    {"write", _PyCFunction_CAST(_io_FileIO_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_write__doc__},
362
363
static PyObject *
364
_io_FileIO_write_impl(fileio *self, PyTypeObject *cls, Py_buffer *b);
365
366
static PyObject *
367
_io_FileIO_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
368
240k
{
369
240k
    PyObject *return_value = NULL;
370
240k
    Py_buffer b = {NULL, NULL};
371
372
240k
    if (!_PyArg_NoKwnames("write", kwnames)) {
373
0
        goto exit;
374
0
    }
375
240k
    if (!_PyArg_CheckPositional("write", nargs, 1, 1)) {
376
0
        goto exit;
377
0
    }
378
240k
    if (PyObject_GetBuffer(args[0], &b, PyBUF_SIMPLE) != 0) {
379
0
        goto exit;
380
0
    }
381
240k
    return_value = _io_FileIO_write_impl((fileio *)self, cls, &b);
382
383
240k
exit:
384
    /* Cleanup for b */
385
240k
    if (b.obj) {
386
240k
       PyBuffer_Release(&b);
387
240k
    }
388
389
240k
    return return_value;
390
240k
}
391
392
PyDoc_STRVAR(_io_FileIO_seek__doc__,
393
"seek($self, pos, whence=0, /)\n"
394
"--\n"
395
"\n"
396
"Move to new file position and return the file position.\n"
397
"\n"
398
"Argument offset is a byte count.  Optional argument whence defaults\n"
399
"to SEEK_SET or 0 (offset from start of file, offset should be >= 0);\n"
400
"other values are SEEK_CUR or 1 (move relative to current position,\n"
401
"positive or negative), and SEEK_END or 2 (move relative to end of\n"
402
"file, usually negative, although many platforms allow seeking beyond\n"
403
"the end of a file).\n"
404
"\n"
405
"Note that not all file objects are seekable.");
406
407
#define _IO_FILEIO_SEEK_METHODDEF    \
408
    {"seek", _PyCFunction_CAST(_io_FileIO_seek), METH_FASTCALL, _io_FileIO_seek__doc__},
409
410
static PyObject *
411
_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);
412
413
static PyObject *
414
_io_FileIO_seek(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
415
0
{
416
0
    PyObject *return_value = NULL;
417
0
    PyObject *pos;
418
0
    int whence = 0;
419
420
0
    if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
421
0
        goto exit;
422
0
    }
423
0
    pos = args[0];
424
0
    if (nargs < 2) {
425
0
        goto skip_optional;
426
0
    }
427
0
    whence = PyLong_AsInt(args[1]);
428
0
    if (whence == -1 && PyErr_Occurred()) {
429
0
        goto exit;
430
0
    }
431
0
skip_optional:
432
0
    return_value = _io_FileIO_seek_impl((fileio *)self, pos, whence);
433
434
0
exit:
435
0
    return return_value;
436
0
}
437
438
PyDoc_STRVAR(_io_FileIO_tell__doc__,
439
"tell($self, /)\n"
440
"--\n"
441
"\n"
442
"Current file position.\n"
443
"\n"
444
"Can raise OSError for non seekable files.");
445
446
#define _IO_FILEIO_TELL_METHODDEF    \
447
    {"tell", (PyCFunction)_io_FileIO_tell, METH_NOARGS, _io_FileIO_tell__doc__},
448
449
static PyObject *
450
_io_FileIO_tell_impl(fileio *self);
451
452
static PyObject *
453
_io_FileIO_tell(PyObject *self, PyObject *Py_UNUSED(ignored))
454
24.7k
{
455
24.7k
    return _io_FileIO_tell_impl((fileio *)self);
456
24.7k
}
457
458
#if defined(HAVE_FTRUNCATE)
459
460
PyDoc_STRVAR(_io_FileIO_truncate__doc__,
461
"truncate($self, size=None, /)\n"
462
"--\n"
463
"\n"
464
"Truncate the file to at most size bytes and return the truncated size.\n"
465
"\n"
466
"Size defaults to the current file position, as returned by tell().\n"
467
"The current file position is changed to the value of size.");
468
469
#define _IO_FILEIO_TRUNCATE_METHODDEF    \
470
    {"truncate", _PyCFunction_CAST(_io_FileIO_truncate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_FileIO_truncate__doc__},
471
472
static PyObject *
473
_io_FileIO_truncate_impl(fileio *self, PyTypeObject *cls, PyObject *posobj);
474
475
static PyObject *
476
_io_FileIO_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
477
0
{
478
0
    PyObject *return_value = NULL;
479
0
    PyObject *posobj = Py_None;
480
481
0
    if (!_PyArg_NoKwnames("truncate", kwnames)) {
482
0
        goto exit;
483
0
    }
484
0
    if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
485
0
        goto exit;
486
0
    }
487
0
    if (nargs < 1) {
488
0
        goto skip_optional;
489
0
    }
490
0
    posobj = args[0];
491
0
skip_optional:
492
0
    return_value = _io_FileIO_truncate_impl((fileio *)self, cls, posobj);
493
494
0
exit:
495
0
    return return_value;
496
0
}
497
498
#endif /* defined(HAVE_FTRUNCATE) */
499
500
PyDoc_STRVAR(_io_FileIO_isatty__doc__,
501
"isatty($self, /)\n"
502
"--\n"
503
"\n"
504
"True if the file is connected to a TTY device.");
505
506
#define _IO_FILEIO_ISATTY_METHODDEF    \
507
    {"isatty", (PyCFunction)_io_FileIO_isatty, METH_NOARGS, _io_FileIO_isatty__doc__},
508
509
static PyObject *
510
_io_FileIO_isatty_impl(fileio *self);
511
512
static PyObject *
513
_io_FileIO_isatty(PyObject *self, PyObject *Py_UNUSED(ignored))
514
111
{
515
111
    return _io_FileIO_isatty_impl((fileio *)self);
516
111
}
517
518
PyDoc_STRVAR(_io_FileIO__isatty_open_only__doc__,
519
"_isatty_open_only($self, /)\n"
520
"--\n"
521
"\n");
522
523
#define _IO_FILEIO__ISATTY_OPEN_ONLY_METHODDEF    \
524
    {"_isatty_open_only", (PyCFunction)_io_FileIO__isatty_open_only, METH_NOARGS, _io_FileIO__isatty_open_only__doc__},
525
526
static PyObject *
527
_io_FileIO__isatty_open_only_impl(fileio *self);
528
529
static PyObject *
530
_io_FileIO__isatty_open_only(PyObject *self, PyObject *Py_UNUSED(ignored))
531
24.6k
{
532
24.6k
    return _io_FileIO__isatty_open_only_impl((fileio *)self);
533
24.6k
}
534
535
PyDoc_STRVAR(_io_FileIO_closed__doc__,
536
"True if the file is closed.");
537
538
static int
539
_io_FileIO_closed_get_impl(fileio *self);
540
541
static PyObject *
542
_io_FileIO_closed_get(PyObject *self, void *Py_UNUSED(context))
543
73.7k
{
544
73.7k
    PyObject *return_value = NULL;
545
73.7k
    int _return_value;
546
547
73.7k
    _return_value = _io_FileIO_closed_get_impl((fileio *)self);
548
73.7k
    if ((_return_value == -1) && PyErr_Occurred()) {
549
0
        goto exit;
550
0
    }
551
73.7k
    return_value = PyBool_FromLong((long)_return_value);
552
553
73.7k
exit:
554
73.7k
    return return_value;
555
73.7k
}
556
557
PyDoc_STRVAR(_io_FileIO_closefd__doc__,
558
"True if the file descriptor will be closed by close().");
559
560
static int
561
_io_FileIO_closefd_get_impl(fileio *self);
562
563
static PyObject *
564
_io_FileIO_closefd_get(PyObject *self, void *Py_UNUSED(context))
565
0
{
566
0
    PyObject *return_value = NULL;
567
0
    int _return_value;
568
569
0
    _return_value = _io_FileIO_closefd_get_impl((fileio *)self);
570
0
    if ((_return_value == -1) && PyErr_Occurred()) {
571
0
        goto exit;
572
0
    }
573
0
    return_value = PyBool_FromLong((long)_return_value);
574
575
0
exit:
576
0
    return return_value;
577
0
}
578
579
PyDoc_STRVAR(_io_FileIO_mode__doc__,
580
"String giving the file mode.");
581
582
static PyObject *
583
_io_FileIO_mode_get_impl(fileio *self);
584
585
static PyObject *
586
_io_FileIO_mode_get(PyObject *self, void *Py_UNUSED(context))
587
3
{
588
3
    return _io_FileIO_mode_get_impl((fileio *)self);
589
3
}
590
591
PyDoc_STRVAR(_io_FileIO__blksize__doc__,
592
"Stat st_blksize if available.");
593
594
static long
595
_io_FileIO__blksize_get_impl(fileio *self);
596
597
static PyObject *
598
_io_FileIO__blksize_get(PyObject *self, void *Py_UNUSED(context))
599
24.6k
{
600
24.6k
    PyObject *return_value = NULL;
601
24.6k
    long _return_value;
602
603
24.6k
    _return_value = _io_FileIO__blksize_get_impl((fileio *)self);
604
24.6k
    if ((_return_value == -1) && PyErr_Occurred()) {
605
0
        goto exit;
606
0
    }
607
24.6k
    return_value = PyLong_FromLong(_return_value);
608
609
24.6k
exit:
610
24.6k
    return return_value;
611
24.6k
}
612
613
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
614
    #define _IO_FILEIO_TRUNCATE_METHODDEF
615
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
616
#define _IO_FILEIO_CLOSED_GETSETDEF {"closed", (getter)_io_FileIO_closed_get, (setter)NULL, _io_FileIO_closed__doc__},
617
618
#define _IO_FILEIO_CLOSEFD_GETSETDEF {"closefd", (getter)_io_FileIO_closefd_get, (setter)NULL, _io_FileIO_closefd__doc__},
619
620
#define _IO_FILEIO_MODE_GETSETDEF {"mode", (getter)_io_FileIO_mode_get, (setter)NULL, _io_FileIO_mode__doc__},
621
622
#define _IO_FILEIO__BLKSIZE_GETSETDEF {"_blksize", (getter)_io_FileIO__blksize_get, (setter)NULL, _io_FileIO__blksize__doc__},
623
624
/*[clinic end generated code: output=b8d6d338bfd0a58f input=a9049054013a1b77]*/