Coverage Report

Created: 2026-02-09 07:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Modules/_io/clinic/bytesio.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
13
PyDoc_STRVAR(_io_BytesIO_readable__doc__,
14
"readable($self, /)\n"
15
"--\n"
16
"\n"
17
"Returns True if the IO object can be read.");
18
19
#define _IO_BYTESIO_READABLE_METHODDEF    \
20
    {"readable", (PyCFunction)_io_BytesIO_readable, METH_NOARGS, _io_BytesIO_readable__doc__},
21
22
static PyObject *
23
_io_BytesIO_readable_impl(bytesio *self);
24
25
static PyObject *
26
_io_BytesIO_readable(PyObject *self, PyObject *Py_UNUSED(ignored))
27
0
{
28
0
    PyObject *return_value = NULL;
29
30
0
    Py_BEGIN_CRITICAL_SECTION(self);
31
0
    return_value = _io_BytesIO_readable_impl((bytesio *)self);
32
0
    Py_END_CRITICAL_SECTION();
33
34
0
    return return_value;
35
0
}
36
37
PyDoc_STRVAR(_io_BytesIO_writable__doc__,
38
"writable($self, /)\n"
39
"--\n"
40
"\n"
41
"Returns True if the IO object can be written.");
42
43
#define _IO_BYTESIO_WRITABLE_METHODDEF    \
44
    {"writable", (PyCFunction)_io_BytesIO_writable, METH_NOARGS, _io_BytesIO_writable__doc__},
45
46
static PyObject *
47
_io_BytesIO_writable_impl(bytesio *self);
48
49
static PyObject *
50
_io_BytesIO_writable(PyObject *self, PyObject *Py_UNUSED(ignored))
51
0
{
52
0
    PyObject *return_value = NULL;
53
54
0
    Py_BEGIN_CRITICAL_SECTION(self);
55
0
    return_value = _io_BytesIO_writable_impl((bytesio *)self);
56
0
    Py_END_CRITICAL_SECTION();
57
58
0
    return return_value;
59
0
}
60
61
PyDoc_STRVAR(_io_BytesIO_seekable__doc__,
62
"seekable($self, /)\n"
63
"--\n"
64
"\n"
65
"Returns True if the IO object can be seeked.");
66
67
#define _IO_BYTESIO_SEEKABLE_METHODDEF    \
68
    {"seekable", (PyCFunction)_io_BytesIO_seekable, METH_NOARGS, _io_BytesIO_seekable__doc__},
69
70
static PyObject *
71
_io_BytesIO_seekable_impl(bytesio *self);
72
73
static PyObject *
74
_io_BytesIO_seekable(PyObject *self, PyObject *Py_UNUSED(ignored))
75
26.6k
{
76
26.6k
    PyObject *return_value = NULL;
77
78
26.6k
    Py_BEGIN_CRITICAL_SECTION(self);
79
26.6k
    return_value = _io_BytesIO_seekable_impl((bytesio *)self);
80
26.6k
    Py_END_CRITICAL_SECTION();
81
82
26.6k
    return return_value;
83
26.6k
}
84
85
PyDoc_STRVAR(_io_BytesIO_flush__doc__,
86
"flush($self, /)\n"
87
"--\n"
88
"\n"
89
"Does nothing.");
90
91
#define _IO_BYTESIO_FLUSH_METHODDEF    \
92
    {"flush", (PyCFunction)_io_BytesIO_flush, METH_NOARGS, _io_BytesIO_flush__doc__},
93
94
static PyObject *
95
_io_BytesIO_flush_impl(bytesio *self);
96
97
static PyObject *
98
_io_BytesIO_flush(PyObject *self, PyObject *Py_UNUSED(ignored))
99
9.59k
{
100
9.59k
    PyObject *return_value = NULL;
101
102
9.59k
    Py_BEGIN_CRITICAL_SECTION(self);
103
9.59k
    return_value = _io_BytesIO_flush_impl((bytesio *)self);
104
9.59k
    Py_END_CRITICAL_SECTION();
105
106
9.59k
    return return_value;
107
9.59k
}
108
109
PyDoc_STRVAR(_io_BytesIO_getbuffer__doc__,
110
"getbuffer($self, /)\n"
111
"--\n"
112
"\n"
113
"Get a read-write view over the contents of the BytesIO object.");
114
115
#define _IO_BYTESIO_GETBUFFER_METHODDEF    \
116
    {"getbuffer", _PyCFunction_CAST(_io_BytesIO_getbuffer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io_BytesIO_getbuffer__doc__},
117
118
static PyObject *
119
_io_BytesIO_getbuffer_impl(bytesio *self, PyTypeObject *cls);
120
121
static PyObject *
122
_io_BytesIO_getbuffer(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
123
0
{
124
0
    PyObject *return_value = NULL;
125
126
0
    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
127
0
        PyErr_SetString(PyExc_TypeError, "getbuffer() takes no arguments");
128
0
        goto exit;
129
0
    }
130
0
    Py_BEGIN_CRITICAL_SECTION(self);
131
0
    return_value = _io_BytesIO_getbuffer_impl((bytesio *)self, cls);
132
0
    Py_END_CRITICAL_SECTION();
133
134
0
exit:
135
0
    return return_value;
136
0
}
137
138
PyDoc_STRVAR(_io_BytesIO_getvalue__doc__,
139
"getvalue($self, /)\n"
140
"--\n"
141
"\n"
142
"Retrieve the entire contents of the BytesIO object.");
143
144
#define _IO_BYTESIO_GETVALUE_METHODDEF    \
145
    {"getvalue", (PyCFunction)_io_BytesIO_getvalue, METH_NOARGS, _io_BytesIO_getvalue__doc__},
146
147
static PyObject *
148
_io_BytesIO_getvalue_impl(bytesio *self);
149
150
static PyObject *
151
_io_BytesIO_getvalue(PyObject *self, PyObject *Py_UNUSED(ignored))
152
282
{
153
282
    PyObject *return_value = NULL;
154
155
282
    Py_BEGIN_CRITICAL_SECTION(self);
156
282
    return_value = _io_BytesIO_getvalue_impl((bytesio *)self);
157
282
    Py_END_CRITICAL_SECTION();
158
159
282
    return return_value;
160
282
}
161
162
PyDoc_STRVAR(_io_BytesIO_isatty__doc__,
163
"isatty($self, /)\n"
164
"--\n"
165
"\n"
166
"Always returns False.\n"
167
"\n"
168
"BytesIO objects are not connected to a TTY-like device.");
169
170
#define _IO_BYTESIO_ISATTY_METHODDEF    \
171
    {"isatty", (PyCFunction)_io_BytesIO_isatty, METH_NOARGS, _io_BytesIO_isatty__doc__},
172
173
static PyObject *
174
_io_BytesIO_isatty_impl(bytesio *self);
175
176
static PyObject *
177
_io_BytesIO_isatty(PyObject *self, PyObject *Py_UNUSED(ignored))
178
0
{
179
0
    PyObject *return_value = NULL;
180
181
0
    Py_BEGIN_CRITICAL_SECTION(self);
182
0
    return_value = _io_BytesIO_isatty_impl((bytesio *)self);
183
0
    Py_END_CRITICAL_SECTION();
184
185
0
    return return_value;
186
0
}
187
188
PyDoc_STRVAR(_io_BytesIO_tell__doc__,
189
"tell($self, /)\n"
190
"--\n"
191
"\n"
192
"Current file position, an integer.");
193
194
#define _IO_BYTESIO_TELL_METHODDEF    \
195
    {"tell", (PyCFunction)_io_BytesIO_tell, METH_NOARGS, _io_BytesIO_tell__doc__},
196
197
static PyObject *
198
_io_BytesIO_tell_impl(bytesio *self);
199
200
static PyObject *
201
_io_BytesIO_tell(PyObject *self, PyObject *Py_UNUSED(ignored))
202
135k
{
203
135k
    PyObject *return_value = NULL;
204
205
135k
    Py_BEGIN_CRITICAL_SECTION(self);
206
135k
    return_value = _io_BytesIO_tell_impl((bytesio *)self);
207
135k
    Py_END_CRITICAL_SECTION();
208
209
135k
    return return_value;
210
135k
}
211
212
PyDoc_STRVAR(_io_BytesIO_read__doc__,
213
"read($self, size=-1, /)\n"
214
"--\n"
215
"\n"
216
"Read at most size bytes, returned as a bytes object.\n"
217
"\n"
218
"If the size argument is negative, read until EOF is reached.\n"
219
"Return an empty bytes object at EOF.");
220
221
#define _IO_BYTESIO_READ_METHODDEF    \
222
    {"read", _PyCFunction_CAST(_io_BytesIO_read), METH_FASTCALL, _io_BytesIO_read__doc__},
223
224
static PyObject *
225
_io_BytesIO_read_impl(bytesio *self, Py_ssize_t size);
226
227
static PyObject *
228
_io_BytesIO_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
229
3.30M
{
230
3.30M
    PyObject *return_value = NULL;
231
3.30M
    Py_ssize_t size = -1;
232
233
3.30M
    if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
234
0
        goto exit;
235
0
    }
236
3.30M
    if (nargs < 1) {
237
0
        goto skip_optional;
238
0
    }
239
3.30M
    if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
240
0
        goto exit;
241
0
    }
242
3.30M
skip_optional:
243
3.30M
    Py_BEGIN_CRITICAL_SECTION(self);
244
3.30M
    return_value = _io_BytesIO_read_impl((bytesio *)self, size);
245
3.30M
    Py_END_CRITICAL_SECTION();
246
247
3.30M
exit:
248
3.30M
    return return_value;
249
3.30M
}
250
251
PyDoc_STRVAR(_io_BytesIO_read1__doc__,
252
"read1($self, size=-1, /)\n"
253
"--\n"
254
"\n"
255
"Read at most size bytes, returned as a bytes object.\n"
256
"\n"
257
"If the size argument is negative or omitted, read until EOF is reached.\n"
258
"Return an empty bytes object at EOF.");
259
260
#define _IO_BYTESIO_READ1_METHODDEF    \
261
    {"read1", _PyCFunction_CAST(_io_BytesIO_read1), METH_FASTCALL, _io_BytesIO_read1__doc__},
262
263
static PyObject *
264
_io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size);
265
266
static PyObject *
267
_io_BytesIO_read1(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
268
0
{
269
0
    PyObject *return_value = NULL;
270
0
    Py_ssize_t size = -1;
271
272
0
    if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
273
0
        goto exit;
274
0
    }
275
0
    if (nargs < 1) {
276
0
        goto skip_optional;
277
0
    }
278
0
    if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
279
0
        goto exit;
280
0
    }
281
0
skip_optional:
282
0
    Py_BEGIN_CRITICAL_SECTION(self);
283
0
    return_value = _io_BytesIO_read1_impl((bytesio *)self, size);
284
0
    Py_END_CRITICAL_SECTION();
285
286
0
exit:
287
0
    return return_value;
288
0
}
289
290
PyDoc_STRVAR(_io_BytesIO_readline__doc__,
291
"readline($self, size=-1, /)\n"
292
"--\n"
293
"\n"
294
"Next line from the file, as a bytes object.\n"
295
"\n"
296
"Retain newline.  A non-negative size argument limits the maximum\n"
297
"number of bytes to return (an incomplete line may be returned then).\n"
298
"Return an empty bytes object at EOF.");
299
300
#define _IO_BYTESIO_READLINE_METHODDEF    \
301
    {"readline", _PyCFunction_CAST(_io_BytesIO_readline), METH_FASTCALL, _io_BytesIO_readline__doc__},
302
303
static PyObject *
304
_io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size);
305
306
static PyObject *
307
_io_BytesIO_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
308
140k
{
309
140k
    PyObject *return_value = NULL;
310
140k
    Py_ssize_t size = -1;
311
312
140k
    if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
313
0
        goto exit;
314
0
    }
315
140k
    if (nargs < 1) {
316
0
        goto skip_optional;
317
0
    }
318
140k
    if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
319
0
        goto exit;
320
0
    }
321
140k
skip_optional:
322
140k
    Py_BEGIN_CRITICAL_SECTION(self);
323
140k
    return_value = _io_BytesIO_readline_impl((bytesio *)self, size);
324
140k
    Py_END_CRITICAL_SECTION();
325
326
140k
exit:
327
140k
    return return_value;
328
140k
}
329
330
PyDoc_STRVAR(_io_BytesIO_readlines__doc__,
331
"readlines($self, size=None, /)\n"
332
"--\n"
333
"\n"
334
"List of bytes objects, each a line from the file.\n"
335
"\n"
336
"Call readline() repeatedly and return a list of the lines so read.\n"
337
"The optional size argument, if given, is an approximate bound on the\n"
338
"total number of bytes in the lines returned.");
339
340
#define _IO_BYTESIO_READLINES_METHODDEF    \
341
    {"readlines", _PyCFunction_CAST(_io_BytesIO_readlines), METH_FASTCALL, _io_BytesIO_readlines__doc__},
342
343
static PyObject *
344
_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
345
346
static PyObject *
347
_io_BytesIO_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
348
0
{
349
0
    PyObject *return_value = NULL;
350
0
    PyObject *arg = Py_None;
351
352
0
    if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
353
0
        goto exit;
354
0
    }
355
0
    if (nargs < 1) {
356
0
        goto skip_optional;
357
0
    }
358
0
    arg = args[0];
359
0
skip_optional:
360
0
    Py_BEGIN_CRITICAL_SECTION(self);
361
0
    return_value = _io_BytesIO_readlines_impl((bytesio *)self, arg);
362
0
    Py_END_CRITICAL_SECTION();
363
364
0
exit:
365
0
    return return_value;
366
0
}
367
368
PyDoc_STRVAR(_io_BytesIO_readinto__doc__,
369
"readinto($self, buffer, /)\n"
370
"--\n"
371
"\n"
372
"Read bytes into buffer.\n"
373
"\n"
374
"Returns number of bytes read (0 for EOF), or None if the object\n"
375
"is set not to block and has no data to read.");
376
377
#define _IO_BYTESIO_READINTO_METHODDEF    \
378
    {"readinto", (PyCFunction)_io_BytesIO_readinto, METH_O, _io_BytesIO_readinto__doc__},
379
380
static PyObject *
381
_io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer);
382
383
static PyObject *
384
_io_BytesIO_readinto(PyObject *self, PyObject *arg)
385
0
{
386
0
    PyObject *return_value = NULL;
387
0
    Py_buffer buffer = {NULL, NULL};
388
389
0
    if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
390
0
        _PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
391
0
        goto exit;
392
0
    }
393
0
    Py_BEGIN_CRITICAL_SECTION(self);
394
0
    return_value = _io_BytesIO_readinto_impl((bytesio *)self, &buffer);
395
0
    Py_END_CRITICAL_SECTION();
396
397
0
exit:
398
    /* Cleanup for buffer */
399
0
    if (buffer.obj) {
400
0
       PyBuffer_Release(&buffer);
401
0
    }
402
403
0
    return return_value;
404
0
}
405
406
PyDoc_STRVAR(_io_BytesIO_truncate__doc__,
407
"truncate($self, size=None, /)\n"
408
"--\n"
409
"\n"
410
"Truncate the file to at most size bytes.\n"
411
"\n"
412
"Size defaults to the current file position, as returned by tell().\n"
413
"The current file position is unchanged.  Returns the new size.");
414
415
#define _IO_BYTESIO_TRUNCATE_METHODDEF    \
416
    {"truncate", _PyCFunction_CAST(_io_BytesIO_truncate), METH_FASTCALL, _io_BytesIO_truncate__doc__},
417
418
static PyObject *
419
_io_BytesIO_truncate_impl(bytesio *self, PyObject *size);
420
421
static PyObject *
422
_io_BytesIO_truncate(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
423
0
{
424
0
    PyObject *return_value = NULL;
425
0
    PyObject *size = Py_None;
426
427
0
    if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
428
0
        goto exit;
429
0
    }
430
0
    if (nargs < 1) {
431
0
        goto skip_optional;
432
0
    }
433
0
    size = args[0];
434
0
skip_optional:
435
0
    Py_BEGIN_CRITICAL_SECTION(self);
436
0
    return_value = _io_BytesIO_truncate_impl((bytesio *)self, size);
437
0
    Py_END_CRITICAL_SECTION();
438
439
0
exit:
440
0
    return return_value;
441
0
}
442
443
PyDoc_STRVAR(_io_BytesIO_seek__doc__,
444
"seek($self, pos, whence=0, /)\n"
445
"--\n"
446
"\n"
447
"Change stream position.\n"
448
"\n"
449
"Seek to byte offset pos relative to position indicated by whence:\n"
450
"     0  Start of stream (the default).  pos should be >= 0;\n"
451
"     1  Current position - pos may be negative;\n"
452
"     2  End of stream - pos usually negative.\n"
453
"Returns the new absolute position.");
454
455
#define _IO_BYTESIO_SEEK_METHODDEF    \
456
    {"seek", _PyCFunction_CAST(_io_BytesIO_seek), METH_FASTCALL, _io_BytesIO_seek__doc__},
457
458
static PyObject *
459
_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);
460
461
static PyObject *
462
_io_BytesIO_seek(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
463
167k
{
464
167k
    PyObject *return_value = NULL;
465
167k
    Py_ssize_t pos;
466
167k
    int whence = 0;
467
468
167k
    if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
469
0
        goto exit;
470
0
    }
471
167k
    {
472
167k
        Py_ssize_t ival = -1;
473
167k
        PyObject *iobj = _PyNumber_Index(args[0]);
474
167k
        if (iobj != NULL) {
475
167k
            ival = PyLong_AsSsize_t(iobj);
476
167k
            Py_DECREF(iobj);
477
167k
        }
478
167k
        if (ival == -1 && PyErr_Occurred()) {
479
120
            goto exit;
480
120
        }
481
167k
        pos = ival;
482
167k
    }
483
167k
    if (nargs < 2) {
484
136k
        goto skip_optional;
485
136k
    }
486
31.3k
    whence = PyLong_AsInt(args[1]);
487
31.3k
    if (whence == -1 && PyErr_Occurred()) {
488
0
        goto exit;
489
0
    }
490
167k
skip_optional:
491
167k
    Py_BEGIN_CRITICAL_SECTION(self);
492
167k
    return_value = _io_BytesIO_seek_impl((bytesio *)self, pos, whence);
493
167k
    Py_END_CRITICAL_SECTION();
494
495
167k
exit:
496
167k
    return return_value;
497
167k
}
498
499
PyDoc_STRVAR(_io_BytesIO_write__doc__,
500
"write($self, b, /)\n"
501
"--\n"
502
"\n"
503
"Write bytes to file.\n"
504
"\n"
505
"Return the number of bytes written.");
506
507
#define _IO_BYTESIO_WRITE_METHODDEF    \
508
    {"write", (PyCFunction)_io_BytesIO_write, METH_O, _io_BytesIO_write__doc__},
509
510
static PyObject *
511
_io_BytesIO_write_impl(bytesio *self, PyObject *b);
512
513
static PyObject *
514
_io_BytesIO_write(PyObject *self, PyObject *b)
515
2.55k
{
516
2.55k
    PyObject *return_value = NULL;
517
518
2.55k
    Py_BEGIN_CRITICAL_SECTION(self);
519
2.55k
    return_value = _io_BytesIO_write_impl((bytesio *)self, b);
520
2.55k
    Py_END_CRITICAL_SECTION();
521
522
2.55k
    return return_value;
523
2.55k
}
524
525
PyDoc_STRVAR(_io_BytesIO_writelines__doc__,
526
"writelines($self, lines, /)\n"
527
"--\n"
528
"\n"
529
"Write lines to the file.\n"
530
"\n"
531
"Note that newlines are not added.  lines can be any iterable object\n"
532
"producing bytes-like objects. This is equivalent to calling write() for\n"
533
"each element.");
534
535
#define _IO_BYTESIO_WRITELINES_METHODDEF    \
536
    {"writelines", (PyCFunction)_io_BytesIO_writelines, METH_O, _io_BytesIO_writelines__doc__},
537
538
static PyObject *
539
_io_BytesIO_writelines_impl(bytesio *self, PyObject *lines);
540
541
static PyObject *
542
_io_BytesIO_writelines(PyObject *self, PyObject *lines)
543
0
{
544
0
    PyObject *return_value = NULL;
545
546
0
    Py_BEGIN_CRITICAL_SECTION(self);
547
0
    return_value = _io_BytesIO_writelines_impl((bytesio *)self, lines);
548
0
    Py_END_CRITICAL_SECTION();
549
550
0
    return return_value;
551
0
}
552
553
PyDoc_STRVAR(_io_BytesIO_close__doc__,
554
"close($self, /)\n"
555
"--\n"
556
"\n"
557
"Disable all I/O operations.");
558
559
#define _IO_BYTESIO_CLOSE_METHODDEF    \
560
    {"close", (PyCFunction)_io_BytesIO_close, METH_NOARGS, _io_BytesIO_close__doc__},
561
562
static PyObject *
563
_io_BytesIO_close_impl(bytesio *self);
564
565
static PyObject *
566
_io_BytesIO_close(PyObject *self, PyObject *Py_UNUSED(ignored))
567
9.92k
{
568
9.92k
    PyObject *return_value = NULL;
569
570
9.92k
    Py_BEGIN_CRITICAL_SECTION(self);
571
9.92k
    return_value = _io_BytesIO_close_impl((bytesio *)self);
572
9.92k
    Py_END_CRITICAL_SECTION();
573
574
9.92k
    return return_value;
575
9.92k
}
576
577
PyDoc_STRVAR(_io_BytesIO___init____doc__,
578
"BytesIO(initial_bytes=b\'\')\n"
579
"--\n"
580
"\n"
581
"Buffered I/O implementation using an in-memory bytes buffer.");
582
583
static int
584
_io_BytesIO___init___impl(bytesio *self, PyObject *initvalue);
585
586
static int
587
_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
588
38.6k
{
589
38.6k
    int return_value = -1;
590
38.6k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
591
592
38.6k
    #define NUM_KEYWORDS 1
593
38.6k
    static struct {
594
38.6k
        PyGC_Head _this_is_not_used;
595
38.6k
        PyObject_VAR_HEAD
596
38.6k
        Py_hash_t ob_hash;
597
38.6k
        PyObject *ob_item[NUM_KEYWORDS];
598
38.6k
    } _kwtuple = {
599
38.6k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
600
38.6k
        .ob_hash = -1,
601
38.6k
        .ob_item = { &_Py_ID(initial_bytes), },
602
38.6k
    };
603
38.6k
    #undef NUM_KEYWORDS
604
38.6k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
605
606
    #else  // !Py_BUILD_CORE
607
    #  define KWTUPLE NULL
608
    #endif  // !Py_BUILD_CORE
609
610
38.6k
    static const char * const _keywords[] = {"initial_bytes", NULL};
611
38.6k
    static _PyArg_Parser _parser = {
612
38.6k
        .keywords = _keywords,
613
38.6k
        .fname = "BytesIO",
614
38.6k
        .kwtuple = KWTUPLE,
615
38.6k
    };
616
38.6k
    #undef KWTUPLE
617
38.6k
    PyObject *argsbuf[1];
618
38.6k
    PyObject * const *fastargs;
619
38.6k
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
620
38.6k
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
621
38.6k
    PyObject *initvalue = NULL;
622
623
38.6k
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
624
38.6k
            /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
625
38.6k
    if (!fastargs) {
626
0
        goto exit;
627
0
    }
628
38.6k
    if (!noptargs) {
629
395
        goto skip_optional_pos;
630
395
    }
631
38.2k
    initvalue = fastargs[0];
632
38.6k
skip_optional_pos:
633
38.6k
    Py_BEGIN_CRITICAL_SECTION(self);
634
38.6k
    return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
635
38.6k
    Py_END_CRITICAL_SECTION();
636
637
38.6k
exit:
638
38.6k
    return return_value;
639
38.6k
}
640
/*[clinic end generated code: output=daa81dfdae5ccc57 input=a9049054013a1b77]*/