| 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" // _PyNumber_Index() |
| 10 |
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
| 11 |
#include "pycore_modsupport.h" // _PyArg_BadArgument() |
| 12 |
|
| 13 |
PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__, |
| 14 |
"readinto($self, buffer, /)\n" |
| 15 |
"--\n" |
| 16 |
"\n"); |
| 17 |
|
| 18 |
#define _IO__BUFFEREDIOBASE_READINTO_METHODDEF \ |
| 19 |
{"readinto", (PyCFunction)_io__BufferedIOBase_readinto, METH_O, _io__BufferedIOBase_readinto__doc__}, |
| 20 |
|
| 21 |
static PyObject * |
| 22 |
_io__BufferedIOBase_readinto_impl(PyObject *self, Py_buffer *buffer); |
| 23 |
|
| 24 |
static PyObject * |
| 25 |
_io__BufferedIOBase_readinto(PyObject *self, PyObject *arg) |
| 26 |
{ |
| 27 |
PyObject *return_value = NULL; |
| 28 |
Py_buffer buffer = {NULL, NULL}; |
| 29 |
|
| 30 |
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { |
| 31 |
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); |
| 32 |
goto exit; |
| 33 |
} |
| 34 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 35 |
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer); |
| 36 |
Py_END_CRITICAL_SECTION(); |
| 37 |
|
| 38 |
exit: |
| 39 |
/* Cleanup for buffer */ |
| 40 |
if (buffer.obj) { |
| 41 |
PyBuffer_Release(&buffer); |
| 42 |
} |
| 43 |
|
| 44 |
return return_value; |
| 45 |
} |
| 46 |
|
| 47 |
PyDoc_STRVAR(_io__BufferedIOBase_readinto1__doc__, |
| 48 |
"readinto1($self, buffer, /)\n" |
| 49 |
"--\n" |
| 50 |
"\n"); |
| 51 |
|
| 52 |
#define _IO__BUFFEREDIOBASE_READINTO1_METHODDEF \ |
| 53 |
{"readinto1", (PyCFunction)_io__BufferedIOBase_readinto1, METH_O, _io__BufferedIOBase_readinto1__doc__}, |
| 54 |
|
| 55 |
static PyObject * |
| 56 |
_io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer); |
| 57 |
|
| 58 |
static PyObject * |
| 59 |
_io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg) |
| 60 |
{ |
| 61 |
PyObject *return_value = NULL; |
| 62 |
Py_buffer buffer = {NULL, NULL}; |
| 63 |
|
| 64 |
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { |
| 65 |
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); |
| 66 |
goto exit; |
| 67 |
} |
| 68 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 69 |
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer); |
| 70 |
Py_END_CRITICAL_SECTION(); |
| 71 |
|
| 72 |
exit: |
| 73 |
/* Cleanup for buffer */ |
| 74 |
if (buffer.obj) { |
| 75 |
PyBuffer_Release(&buffer); |
| 76 |
} |
| 77 |
|
| 78 |
return return_value; |
| 79 |
} |
| 80 |
|
| 81 |
PyDoc_STRVAR(_io__BufferedIOBase_detach__doc__, |
| 82 |
"detach($self, /)\n" |
| 83 |
"--\n" |
| 84 |
"\n" |
| 85 |
"Disconnect this buffer from its underlying raw stream and return it.\n" |
| 86 |
"\n" |
| 87 |
"After the raw stream has been detached, the buffer is in an unusable\n" |
| 88 |
"state."); |
| 89 |
|
| 90 |
#define _IO__BUFFEREDIOBASE_DETACH_METHODDEF \ |
| 91 |
{"detach", _PyCFunction_CAST(_io__BufferedIOBase_detach), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__BufferedIOBase_detach__doc__}, |
| 92 |
|
| 93 |
static PyObject * |
| 94 |
_io__BufferedIOBase_detach_impl(PyObject *self, PyTypeObject *cls); |
| 95 |
|
| 96 |
static PyObject * |
| 97 |
_io__BufferedIOBase_detach(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 98 |
{ |
| 99 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 100 |
PyErr_SetString(PyExc_TypeError, "detach() takes no arguments"); |
| 101 |
return NULL; |
| 102 |
} |
| 103 |
return _io__BufferedIOBase_detach_impl(self, cls); |
| 104 |
} |
| 105 |
|
| 106 |
PyDoc_STRVAR(_io__BufferedIOBase_read__doc__, |
| 107 |
"read($self, size=-1, /)\n" |
| 108 |
"--\n" |
| 109 |
"\n" |
| 110 |
"Read and return up to n bytes.\n" |
| 111 |
"\n" |
| 112 |
"If the size argument is omitted, None, or negative, read and\n" |
| 113 |
"return all data until EOF.\n" |
| 114 |
"\n" |
| 115 |
"If the size argument is positive, and the underlying raw stream is\n" |
| 116 |
"not \'interactive\', multiple raw reads may be issued to satisfy\n" |
| 117 |
"the byte count (unless EOF is reached first).\n" |
| 118 |
"However, for interactive raw streams (as well as sockets and pipes),\n" |
| 119 |
"at most one raw read will be issued, and a short result does not\n" |
| 120 |
"imply that EOF is imminent.\n" |
| 121 |
"\n" |
| 122 |
"Return an empty bytes object on EOF.\n" |
| 123 |
"\n" |
| 124 |
"Return None if the underlying raw stream was open in non-blocking\n" |
| 125 |
"mode and no data is available at the moment."); |
| 126 |
|
| 127 |
#define _IO__BUFFEREDIOBASE_READ_METHODDEF \ |
| 128 |
{"read", _PyCFunction_CAST(_io__BufferedIOBase_read), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__BufferedIOBase_read__doc__}, |
| 129 |
|
| 130 |
static PyObject * |
| 131 |
_io__BufferedIOBase_read_impl(PyObject *self, PyTypeObject *cls, |
| 132 |
int Py_UNUSED(size)); |
| 133 |
|
| 134 |
static PyObject * |
| 135 |
_io__BufferedIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 136 |
{ |
| 137 |
PyObject *return_value = NULL; |
| 138 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 139 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 140 |
#else |
| 141 |
# define KWTUPLE NULL |
| 142 |
#endif |
| 143 |
|
| 144 |
static const char * const _keywords[] = {"", NULL}; |
| 145 |
static _PyArg_Parser _parser = { |
| 146 |
.keywords = _keywords, |
| 147 |
.fname = "read", |
| 148 |
.kwtuple = KWTUPLE, |
| 149 |
}; |
| 150 |
#undef KWTUPLE |
| 151 |
PyObject *argsbuf[1]; |
| 152 |
int size = -1; |
| 153 |
|
| 154 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 155 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 156 |
if (!args) { |
| 157 |
goto exit; |
| 158 |
} |
| 159 |
if (nargs < 1) { |
| 160 |
goto skip_optional_posonly; |
| 161 |
} |
| 162 |
size = PyLong_AsInt(args[0]); |
| 163 |
if (size == -1 && PyErr_Occurred()) { |
| 164 |
goto exit; |
| 165 |
} |
| 166 |
skip_optional_posonly: |
| 167 |
return_value = _io__BufferedIOBase_read_impl(self, cls, size); |
| 168 |
|
| 169 |
exit: |
| 170 |
return return_value; |
| 171 |
} |
| 172 |
|
| 173 |
PyDoc_STRVAR(_io__BufferedIOBase_read1__doc__, |
| 174 |
"read1($self, size=-1, /)\n" |
| 175 |
"--\n" |
| 176 |
"\n" |
| 177 |
"Read and return up to size bytes, with at most one read() call to the underlying raw stream.\n" |
| 178 |
"\n" |
| 179 |
"Return an empty bytes object on EOF.\n" |
| 180 |
"A short result does not imply that EOF is imminent."); |
| 181 |
|
| 182 |
#define _IO__BUFFEREDIOBASE_READ1_METHODDEF \ |
| 183 |
{"read1", _PyCFunction_CAST(_io__BufferedIOBase_read1), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__BufferedIOBase_read1__doc__}, |
| 184 |
|
| 185 |
static PyObject * |
| 186 |
_io__BufferedIOBase_read1_impl(PyObject *self, PyTypeObject *cls, |
| 187 |
int Py_UNUSED(size)); |
| 188 |
|
| 189 |
static PyObject * |
| 190 |
_io__BufferedIOBase_read1(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 191 |
{ |
| 192 |
PyObject *return_value = NULL; |
| 193 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 194 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 195 |
#else |
| 196 |
# define KWTUPLE NULL |
| 197 |
#endif |
| 198 |
|
| 199 |
static const char * const _keywords[] = {"", NULL}; |
| 200 |
static _PyArg_Parser _parser = { |
| 201 |
.keywords = _keywords, |
| 202 |
.fname = "read1", |
| 203 |
.kwtuple = KWTUPLE, |
| 204 |
}; |
| 205 |
#undef KWTUPLE |
| 206 |
PyObject *argsbuf[1]; |
| 207 |
int size = -1; |
| 208 |
|
| 209 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 210 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 211 |
if (!args) { |
| 212 |
goto exit; |
| 213 |
} |
| 214 |
if (nargs < 1) { |
| 215 |
goto skip_optional_posonly; |
| 216 |
} |
| 217 |
size = PyLong_AsInt(args[0]); |
| 218 |
if (size == -1 && PyErr_Occurred()) { |
| 219 |
goto exit; |
| 220 |
} |
| 221 |
skip_optional_posonly: |
| 222 |
return_value = _io__BufferedIOBase_read1_impl(self, cls, size); |
| 223 |
|
| 224 |
exit: |
| 225 |
return return_value; |
| 226 |
} |
| 227 |
|
| 228 |
PyDoc_STRVAR(_io__BufferedIOBase_write__doc__, |
| 229 |
"write($self, b, /)\n" |
| 230 |
"--\n" |
| 231 |
"\n" |
| 232 |
"Write buffer b to the IO stream.\n" |
| 233 |
"\n" |
| 234 |
"Return the number of bytes written, which is always\n" |
| 235 |
"the length of b in bytes.\n" |
| 236 |
"\n" |
| 237 |
"Raise BlockingIOError if the buffer is full and the\n" |
| 238 |
"underlying raw stream cannot accept more data at the moment."); |
| 239 |
|
| 240 |
#define _IO__BUFFEREDIOBASE_WRITE_METHODDEF \ |
| 241 |
{"write", _PyCFunction_CAST(_io__BufferedIOBase_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__BufferedIOBase_write__doc__}, |
| 242 |
|
| 243 |
static PyObject * |
| 244 |
_io__BufferedIOBase_write_impl(PyObject *self, PyTypeObject *cls, |
| 245 |
PyObject *Py_UNUSED(b)); |
| 246 |
|
| 247 |
static PyObject * |
| 248 |
_io__BufferedIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 249 |
{ |
| 250 |
PyObject *return_value = NULL; |
| 251 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 252 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 253 |
#else |
| 254 |
# define KWTUPLE NULL |
| 255 |
#endif |
| 256 |
|
| 257 |
static const char * const _keywords[] = {"", NULL}; |
| 258 |
static _PyArg_Parser _parser = { |
| 259 |
.keywords = _keywords, |
| 260 |
.fname = "write", |
| 261 |
.kwtuple = KWTUPLE, |
| 262 |
}; |
| 263 |
#undef KWTUPLE |
| 264 |
PyObject *argsbuf[1]; |
| 265 |
PyObject *b; |
| 266 |
|
| 267 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 268 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 269 |
if (!args) { |
| 270 |
goto exit; |
| 271 |
} |
| 272 |
b = args[0]; |
| 273 |
return_value = _io__BufferedIOBase_write_impl(self, cls, b); |
| 274 |
|
| 275 |
exit: |
| 276 |
return return_value; |
| 277 |
} |
| 278 |
|
| 279 |
PyDoc_STRVAR(_io__Buffered___sizeof____doc__, |
| 280 |
"__sizeof__($self, /)\n" |
| 281 |
"--\n" |
| 282 |
"\n"); |
| 283 |
|
| 284 |
#define _IO__BUFFERED___SIZEOF___METHODDEF \ |
| 285 |
{"__sizeof__", (PyCFunction)_io__Buffered___sizeof__, METH_NOARGS, _io__Buffered___sizeof____doc__}, |
| 286 |
|
| 287 |
static PyObject * |
| 288 |
_io__Buffered___sizeof___impl(buffered *self); |
| 289 |
|
| 290 |
static PyObject * |
| 291 |
_io__Buffered___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 292 |
{ |
| 293 |
PyObject *return_value = NULL; |
| 294 |
|
| 295 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 296 |
return_value = _io__Buffered___sizeof___impl((buffered *)self); |
| 297 |
Py_END_CRITICAL_SECTION(); |
| 298 |
|
| 299 |
return return_value; |
| 300 |
} |
| 301 |
|
| 302 |
PyDoc_STRVAR(_io__Buffered__dealloc_warn__doc__, |
| 303 |
"_dealloc_warn($self, source, /)\n" |
| 304 |
"--\n" |
| 305 |
"\n"); |
| 306 |
|
| 307 |
#define _IO__BUFFERED__DEALLOC_WARN_METHODDEF \ |
| 308 |
{"_dealloc_warn", (PyCFunction)_io__Buffered__dealloc_warn, METH_O, _io__Buffered__dealloc_warn__doc__}, |
| 309 |
|
| 310 |
static PyObject * |
| 311 |
_io__Buffered__dealloc_warn_impl(buffered *self, PyObject *source); |
| 312 |
|
| 313 |
static PyObject * |
| 314 |
_io__Buffered__dealloc_warn(PyObject *self, PyObject *source) |
| 315 |
{ |
| 316 |
PyObject *return_value = NULL; |
| 317 |
|
| 318 |
return_value = _io__Buffered__dealloc_warn_impl((buffered *)self, source); |
| 319 |
|
| 320 |
return return_value; |
| 321 |
} |
| 322 |
|
| 323 |
PyDoc_STRVAR(_io__Buffered_simple_flush__doc__, |
| 324 |
"flush($self, /)\n" |
| 325 |
"--\n" |
| 326 |
"\n"); |
| 327 |
|
| 328 |
#define _IO__BUFFERED_SIMPLE_FLUSH_METHODDEF \ |
| 329 |
{"flush", (PyCFunction)_io__Buffered_simple_flush, METH_NOARGS, _io__Buffered_simple_flush__doc__}, |
| 330 |
|
| 331 |
static PyObject * |
| 332 |
_io__Buffered_simple_flush_impl(buffered *self); |
| 333 |
|
| 334 |
static PyObject * |
| 335 |
_io__Buffered_simple_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 336 |
{ |
| 337 |
PyObject *return_value = NULL; |
| 338 |
|
| 339 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 340 |
return_value = _io__Buffered_simple_flush_impl((buffered *)self); |
| 341 |
Py_END_CRITICAL_SECTION(); |
| 342 |
|
| 343 |
return return_value; |
| 344 |
} |
| 345 |
|
| 346 |
#if !defined(_io__Buffered_closed_DOCSTR) |
| 347 |
# define _io__Buffered_closed_DOCSTR NULL |
| 348 |
#endif |
| 349 |
#if defined(_IO__BUFFERED_CLOSED_GETSETDEF) |
| 350 |
# undef _IO__BUFFERED_CLOSED_GETSETDEF |
| 351 |
# define _IO__BUFFERED_CLOSED_GETSETDEF {"closed", (getter)_io__Buffered_closed_get, (setter)_io__Buffered_closed_set, _io__Buffered_closed_DOCSTR}, |
| 352 |
#else |
| 353 |
# define _IO__BUFFERED_CLOSED_GETSETDEF {"closed", (getter)_io__Buffered_closed_get, NULL, _io__Buffered_closed_DOCSTR}, |
| 354 |
#endif |
| 355 |
|
| 356 |
static PyObject * |
| 357 |
_io__Buffered_closed_get_impl(buffered *self); |
| 358 |
|
| 359 |
static PyObject * |
| 360 |
_io__Buffered_closed_get(PyObject *self, void *Py_UNUSED(context)) |
| 361 |
{ |
| 362 |
PyObject *return_value = NULL; |
| 363 |
|
| 364 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 365 |
return_value = _io__Buffered_closed_get_impl((buffered *)self); |
| 366 |
Py_END_CRITICAL_SECTION(); |
| 367 |
|
| 368 |
return return_value; |
| 369 |
} |
| 370 |
|
| 371 |
PyDoc_STRVAR(_io__Buffered_close__doc__, |
| 372 |
"close($self, /)\n" |
| 373 |
"--\n" |
| 374 |
"\n"); |
| 375 |
|
| 376 |
#define _IO__BUFFERED_CLOSE_METHODDEF \ |
| 377 |
{"close", (PyCFunction)_io__Buffered_close, METH_NOARGS, _io__Buffered_close__doc__}, |
| 378 |
|
| 379 |
static PyObject * |
| 380 |
_io__Buffered_close_impl(buffered *self); |
| 381 |
|
| 382 |
static PyObject * |
| 383 |
_io__Buffered_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 384 |
{ |
| 385 |
PyObject *return_value = NULL; |
| 386 |
|
| 387 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 388 |
return_value = _io__Buffered_close_impl((buffered *)self); |
| 389 |
Py_END_CRITICAL_SECTION(); |
| 390 |
|
| 391 |
return return_value; |
| 392 |
} |
| 393 |
|
| 394 |
PyDoc_STRVAR(_io__Buffered_detach__doc__, |
| 395 |
"detach($self, /)\n" |
| 396 |
"--\n" |
| 397 |
"\n"); |
| 398 |
|
| 399 |
#define _IO__BUFFERED_DETACH_METHODDEF \ |
| 400 |
{"detach", (PyCFunction)_io__Buffered_detach, METH_NOARGS, _io__Buffered_detach__doc__}, |
| 401 |
|
| 402 |
static PyObject * |
| 403 |
_io__Buffered_detach_impl(buffered *self); |
| 404 |
|
| 405 |
static PyObject * |
| 406 |
_io__Buffered_detach(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 407 |
{ |
| 408 |
PyObject *return_value = NULL; |
| 409 |
|
| 410 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 411 |
return_value = _io__Buffered_detach_impl((buffered *)self); |
| 412 |
Py_END_CRITICAL_SECTION(); |
| 413 |
|
| 414 |
return return_value; |
| 415 |
} |
| 416 |
|
| 417 |
PyDoc_STRVAR(_io__Buffered_seekable__doc__, |
| 418 |
"seekable($self, /)\n" |
| 419 |
"--\n" |
| 420 |
"\n"); |
| 421 |
|
| 422 |
#define _IO__BUFFERED_SEEKABLE_METHODDEF \ |
| 423 |
{"seekable", (PyCFunction)_io__Buffered_seekable, METH_NOARGS, _io__Buffered_seekable__doc__}, |
| 424 |
|
| 425 |
static PyObject * |
| 426 |
_io__Buffered_seekable_impl(buffered *self); |
| 427 |
|
| 428 |
static PyObject * |
| 429 |
_io__Buffered_seekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 430 |
{ |
| 431 |
PyObject *return_value = NULL; |
| 432 |
|
| 433 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 434 |
return_value = _io__Buffered_seekable_impl((buffered *)self); |
| 435 |
Py_END_CRITICAL_SECTION(); |
| 436 |
|
| 437 |
return return_value; |
| 438 |
} |
| 439 |
|
| 440 |
PyDoc_STRVAR(_io__Buffered_readable__doc__, |
| 441 |
"readable($self, /)\n" |
| 442 |
"--\n" |
| 443 |
"\n"); |
| 444 |
|
| 445 |
#define _IO__BUFFERED_READABLE_METHODDEF \ |
| 446 |
{"readable", (PyCFunction)_io__Buffered_readable, METH_NOARGS, _io__Buffered_readable__doc__}, |
| 447 |
|
| 448 |
static PyObject * |
| 449 |
_io__Buffered_readable_impl(buffered *self); |
| 450 |
|
| 451 |
static PyObject * |
| 452 |
_io__Buffered_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 453 |
{ |
| 454 |
PyObject *return_value = NULL; |
| 455 |
|
| 456 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 457 |
return_value = _io__Buffered_readable_impl((buffered *)self); |
| 458 |
Py_END_CRITICAL_SECTION(); |
| 459 |
|
| 460 |
return return_value; |
| 461 |
} |
| 462 |
|
| 463 |
PyDoc_STRVAR(_io__Buffered_writable__doc__, |
| 464 |
"writable($self, /)\n" |
| 465 |
"--\n" |
| 466 |
"\n"); |
| 467 |
|
| 468 |
#define _IO__BUFFERED_WRITABLE_METHODDEF \ |
| 469 |
{"writable", (PyCFunction)_io__Buffered_writable, METH_NOARGS, _io__Buffered_writable__doc__}, |
| 470 |
|
| 471 |
static PyObject * |
| 472 |
_io__Buffered_writable_impl(buffered *self); |
| 473 |
|
| 474 |
static PyObject * |
| 475 |
_io__Buffered_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 476 |
{ |
| 477 |
PyObject *return_value = NULL; |
| 478 |
|
| 479 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 480 |
return_value = _io__Buffered_writable_impl((buffered *)self); |
| 481 |
Py_END_CRITICAL_SECTION(); |
| 482 |
|
| 483 |
return return_value; |
| 484 |
} |
| 485 |
|
| 486 |
#if !defined(_io__Buffered_name_DOCSTR) |
| 487 |
# define _io__Buffered_name_DOCSTR NULL |
| 488 |
#endif |
| 489 |
#if defined(_IO__BUFFERED_NAME_GETSETDEF) |
| 490 |
# undef _IO__BUFFERED_NAME_GETSETDEF |
| 491 |
# define _IO__BUFFERED_NAME_GETSETDEF {"name", (getter)_io__Buffered_name_get, (setter)_io__Buffered_name_set, _io__Buffered_name_DOCSTR}, |
| 492 |
#else |
| 493 |
# define _IO__BUFFERED_NAME_GETSETDEF {"name", (getter)_io__Buffered_name_get, NULL, _io__Buffered_name_DOCSTR}, |
| 494 |
#endif |
| 495 |
|
| 496 |
static PyObject * |
| 497 |
_io__Buffered_name_get_impl(buffered *self); |
| 498 |
|
| 499 |
static PyObject * |
| 500 |
_io__Buffered_name_get(PyObject *self, void *Py_UNUSED(context)) |
| 501 |
{ |
| 502 |
PyObject *return_value = NULL; |
| 503 |
|
| 504 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 505 |
return_value = _io__Buffered_name_get_impl((buffered *)self); |
| 506 |
Py_END_CRITICAL_SECTION(); |
| 507 |
|
| 508 |
return return_value; |
| 509 |
} |
| 510 |
|
| 511 |
#if !defined(_io__Buffered_mode_DOCSTR) |
| 512 |
# define _io__Buffered_mode_DOCSTR NULL |
| 513 |
#endif |
| 514 |
#if defined(_IO__BUFFERED_MODE_GETSETDEF) |
| 515 |
# undef _IO__BUFFERED_MODE_GETSETDEF |
| 516 |
# define _IO__BUFFERED_MODE_GETSETDEF {"mode", (getter)_io__Buffered_mode_get, (setter)_io__Buffered_mode_set, _io__Buffered_mode_DOCSTR}, |
| 517 |
#else |
| 518 |
# define _IO__BUFFERED_MODE_GETSETDEF {"mode", (getter)_io__Buffered_mode_get, NULL, _io__Buffered_mode_DOCSTR}, |
| 519 |
#endif |
| 520 |
|
| 521 |
static PyObject * |
| 522 |
_io__Buffered_mode_get_impl(buffered *self); |
| 523 |
|
| 524 |
static PyObject * |
| 525 |
_io__Buffered_mode_get(PyObject *self, void *Py_UNUSED(context)) |
| 526 |
{ |
| 527 |
PyObject *return_value = NULL; |
| 528 |
|
| 529 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 530 |
return_value = _io__Buffered_mode_get_impl((buffered *)self); |
| 531 |
Py_END_CRITICAL_SECTION(); |
| 532 |
|
| 533 |
return return_value; |
| 534 |
} |
| 535 |
|
| 536 |
PyDoc_STRVAR(_io__Buffered_fileno__doc__, |
| 537 |
"fileno($self, /)\n" |
| 538 |
"--\n" |
| 539 |
"\n"); |
| 540 |
|
| 541 |
#define _IO__BUFFERED_FILENO_METHODDEF \ |
| 542 |
{"fileno", (PyCFunction)_io__Buffered_fileno, METH_NOARGS, _io__Buffered_fileno__doc__}, |
| 543 |
|
| 544 |
static PyObject * |
| 545 |
_io__Buffered_fileno_impl(buffered *self); |
| 546 |
|
| 547 |
static PyObject * |
| 548 |
_io__Buffered_fileno(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 549 |
{ |
| 550 |
PyObject *return_value = NULL; |
| 551 |
|
| 552 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 553 |
return_value = _io__Buffered_fileno_impl((buffered *)self); |
| 554 |
Py_END_CRITICAL_SECTION(); |
| 555 |
|
| 556 |
return return_value; |
| 557 |
} |
| 558 |
|
| 559 |
PyDoc_STRVAR(_io__Buffered_isatty__doc__, |
| 560 |
"isatty($self, /)\n" |
| 561 |
"--\n" |
| 562 |
"\n"); |
| 563 |
|
| 564 |
#define _IO__BUFFERED_ISATTY_METHODDEF \ |
| 565 |
{"isatty", (PyCFunction)_io__Buffered_isatty, METH_NOARGS, _io__Buffered_isatty__doc__}, |
| 566 |
|
| 567 |
static PyObject * |
| 568 |
_io__Buffered_isatty_impl(buffered *self); |
| 569 |
|
| 570 |
static PyObject * |
| 571 |
_io__Buffered_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 572 |
{ |
| 573 |
PyObject *return_value = NULL; |
| 574 |
|
| 575 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 576 |
return_value = _io__Buffered_isatty_impl((buffered *)self); |
| 577 |
Py_END_CRITICAL_SECTION(); |
| 578 |
|
| 579 |
return return_value; |
| 580 |
} |
| 581 |
|
| 582 |
PyDoc_STRVAR(_io__Buffered_flush__doc__, |
| 583 |
"flush($self, /)\n" |
| 584 |
"--\n" |
| 585 |
"\n"); |
| 586 |
|
| 587 |
#define _IO__BUFFERED_FLUSH_METHODDEF \ |
| 588 |
{"flush", (PyCFunction)_io__Buffered_flush, METH_NOARGS, _io__Buffered_flush__doc__}, |
| 589 |
|
| 590 |
static PyObject * |
| 591 |
_io__Buffered_flush_impl(buffered *self); |
| 592 |
|
| 593 |
static PyObject * |
| 594 |
_io__Buffered_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 595 |
{ |
| 596 |
PyObject *return_value = NULL; |
| 597 |
|
| 598 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 599 |
return_value = _io__Buffered_flush_impl((buffered *)self); |
| 600 |
Py_END_CRITICAL_SECTION(); |
| 601 |
|
| 602 |
return return_value; |
| 603 |
} |
| 604 |
|
| 605 |
PyDoc_STRVAR(_io__Buffered_peek__doc__, |
| 606 |
"peek($self, size=0, /)\n" |
| 607 |
"--\n" |
| 608 |
"\n"); |
| 609 |
|
| 610 |
#define _IO__BUFFERED_PEEK_METHODDEF \ |
| 611 |
{"peek", _PyCFunction_CAST(_io__Buffered_peek), METH_FASTCALL, _io__Buffered_peek__doc__}, |
| 612 |
|
| 613 |
static PyObject * |
| 614 |
_io__Buffered_peek_impl(buffered *self, Py_ssize_t size); |
| 615 |
|
| 616 |
static PyObject * |
| 617 |
_io__Buffered_peek(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 618 |
{ |
| 619 |
PyObject *return_value = NULL; |
| 620 |
Py_ssize_t size = 0; |
| 621 |
|
| 622 |
if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) { |
| 623 |
goto exit; |
| 624 |
} |
| 625 |
if (nargs < 1) { |
| 626 |
goto skip_optional; |
| 627 |
} |
| 628 |
{ |
| 629 |
Py_ssize_t ival = -1; |
| 630 |
PyObject *iobj = _PyNumber_Index(args[0]); |
| 631 |
if (iobj != NULL) { |
| 632 |
ival = PyLong_AsSsize_t(iobj); |
| 633 |
Py_DECREF(iobj); |
| 634 |
} |
| 635 |
if (ival == -1 && PyErr_Occurred()) { |
| 636 |
goto exit; |
| 637 |
} |
| 638 |
size = ival; |
| 639 |
} |
| 640 |
skip_optional: |
| 641 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 642 |
return_value = _io__Buffered_peek_impl((buffered *)self, size); |
| 643 |
Py_END_CRITICAL_SECTION(); |
| 644 |
|
| 645 |
exit: |
| 646 |
return return_value; |
| 647 |
} |
| 648 |
|
| 649 |
PyDoc_STRVAR(_io__Buffered_read__doc__, |
| 650 |
"read($self, size=-1, /)\n" |
| 651 |
"--\n" |
| 652 |
"\n"); |
| 653 |
|
| 654 |
#define _IO__BUFFERED_READ_METHODDEF \ |
| 655 |
{"read", _PyCFunction_CAST(_io__Buffered_read), METH_FASTCALL, _io__Buffered_read__doc__}, |
| 656 |
|
| 657 |
static PyObject * |
| 658 |
_io__Buffered_read_impl(buffered *self, Py_ssize_t n); |
| 659 |
|
| 660 |
static PyObject * |
| 661 |
_io__Buffered_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 662 |
{ |
| 663 |
PyObject *return_value = NULL; |
| 664 |
Py_ssize_t n = -1; |
| 665 |
|
| 666 |
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
| 667 |
goto exit; |
| 668 |
} |
| 669 |
if (nargs < 1) { |
| 670 |
goto skip_optional; |
| 671 |
} |
| 672 |
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { |
| 673 |
goto exit; |
| 674 |
} |
| 675 |
skip_optional: |
| 676 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 677 |
return_value = _io__Buffered_read_impl((buffered *)self, n); |
| 678 |
Py_END_CRITICAL_SECTION(); |
| 679 |
|
| 680 |
exit: |
| 681 |
return return_value; |
| 682 |
} |
| 683 |
|
| 684 |
PyDoc_STRVAR(_io__Buffered_read1__doc__, |
| 685 |
"read1($self, size=-1, /)\n" |
| 686 |
"--\n" |
| 687 |
"\n"); |
| 688 |
|
| 689 |
#define _IO__BUFFERED_READ1_METHODDEF \ |
| 690 |
{"read1", _PyCFunction_CAST(_io__Buffered_read1), METH_FASTCALL, _io__Buffered_read1__doc__}, |
| 691 |
|
| 692 |
static PyObject * |
| 693 |
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n); |
| 694 |
|
| 695 |
static PyObject * |
| 696 |
_io__Buffered_read1(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 697 |
{ |
| 698 |
PyObject *return_value = NULL; |
| 699 |
Py_ssize_t n = -1; |
| 700 |
|
| 701 |
if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { |
| 702 |
goto exit; |
| 703 |
} |
| 704 |
if (nargs < 1) { |
| 705 |
goto skip_optional; |
| 706 |
} |
| 707 |
{ |
| 708 |
Py_ssize_t ival = -1; |
| 709 |
PyObject *iobj = _PyNumber_Index(args[0]); |
| 710 |
if (iobj != NULL) { |
| 711 |
ival = PyLong_AsSsize_t(iobj); |
| 712 |
Py_DECREF(iobj); |
| 713 |
} |
| 714 |
if (ival == -1 && PyErr_Occurred()) { |
| 715 |
goto exit; |
| 716 |
} |
| 717 |
n = ival; |
| 718 |
} |
| 719 |
skip_optional: |
| 720 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 721 |
return_value = _io__Buffered_read1_impl((buffered *)self, n); |
| 722 |
Py_END_CRITICAL_SECTION(); |
| 723 |
|
| 724 |
exit: |
| 725 |
return return_value; |
| 726 |
} |
| 727 |
|
| 728 |
PyDoc_STRVAR(_io__Buffered_readinto__doc__, |
| 729 |
"readinto($self, buffer, /)\n" |
| 730 |
"--\n" |
| 731 |
"\n"); |
| 732 |
|
| 733 |
#define _IO__BUFFERED_READINTO_METHODDEF \ |
| 734 |
{"readinto", (PyCFunction)_io__Buffered_readinto, METH_O, _io__Buffered_readinto__doc__}, |
| 735 |
|
| 736 |
static PyObject * |
| 737 |
_io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer); |
| 738 |
|
| 739 |
static PyObject * |
| 740 |
_io__Buffered_readinto(PyObject *self, PyObject *arg) |
| 741 |
{ |
| 742 |
PyObject *return_value = NULL; |
| 743 |
Py_buffer buffer = {NULL, NULL}; |
| 744 |
|
| 745 |
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { |
| 746 |
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg); |
| 747 |
goto exit; |
| 748 |
} |
| 749 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 750 |
return_value = _io__Buffered_readinto_impl((buffered *)self, &buffer); |
| 751 |
Py_END_CRITICAL_SECTION(); |
| 752 |
|
| 753 |
exit: |
| 754 |
/* Cleanup for buffer */ |
| 755 |
if (buffer.obj) { |
| 756 |
PyBuffer_Release(&buffer); |
| 757 |
} |
| 758 |
|
| 759 |
return return_value; |
| 760 |
} |
| 761 |
|
| 762 |
PyDoc_STRVAR(_io__Buffered_readinto1__doc__, |
| 763 |
"readinto1($self, buffer, /)\n" |
| 764 |
"--\n" |
| 765 |
"\n"); |
| 766 |
|
| 767 |
#define _IO__BUFFERED_READINTO1_METHODDEF \ |
| 768 |
{"readinto1", (PyCFunction)_io__Buffered_readinto1, METH_O, _io__Buffered_readinto1__doc__}, |
| 769 |
|
| 770 |
static PyObject * |
| 771 |
_io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer); |
| 772 |
|
| 773 |
static PyObject * |
| 774 |
_io__Buffered_readinto1(PyObject *self, PyObject *arg) |
| 775 |
{ |
| 776 |
PyObject *return_value = NULL; |
| 777 |
Py_buffer buffer = {NULL, NULL}; |
| 778 |
|
| 779 |
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { |
| 780 |
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg); |
| 781 |
goto exit; |
| 782 |
} |
| 783 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 784 |
return_value = _io__Buffered_readinto1_impl((buffered *)self, &buffer); |
| 785 |
Py_END_CRITICAL_SECTION(); |
| 786 |
|
| 787 |
exit: |
| 788 |
/* Cleanup for buffer */ |
| 789 |
if (buffer.obj) { |
| 790 |
PyBuffer_Release(&buffer); |
| 791 |
} |
| 792 |
|
| 793 |
return return_value; |
| 794 |
} |
| 795 |
|
| 796 |
PyDoc_STRVAR(_io__Buffered_readline__doc__, |
| 797 |
"readline($self, size=-1, /)\n" |
| 798 |
"--\n" |
| 799 |
"\n"); |
| 800 |
|
| 801 |
#define _IO__BUFFERED_READLINE_METHODDEF \ |
| 802 |
{"readline", _PyCFunction_CAST(_io__Buffered_readline), METH_FASTCALL, _io__Buffered_readline__doc__}, |
| 803 |
|
| 804 |
static PyObject * |
| 805 |
_io__Buffered_readline_impl(buffered *self, Py_ssize_t size); |
| 806 |
|
| 807 |
static PyObject * |
| 808 |
_io__Buffered_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 809 |
{ |
| 810 |
PyObject *return_value = NULL; |
| 811 |
Py_ssize_t size = -1; |
| 812 |
|
| 813 |
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
| 814 |
goto exit; |
| 815 |
} |
| 816 |
if (nargs < 1) { |
| 817 |
goto skip_optional; |
| 818 |
} |
| 819 |
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { |
| 820 |
goto exit; |
| 821 |
} |
| 822 |
skip_optional: |
| 823 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 824 |
return_value = _io__Buffered_readline_impl((buffered *)self, size); |
| 825 |
Py_END_CRITICAL_SECTION(); |
| 826 |
|
| 827 |
exit: |
| 828 |
return return_value; |
| 829 |
} |
| 830 |
|
| 831 |
PyDoc_STRVAR(_io__Buffered_tell__doc__, |
| 832 |
"tell($self, /)\n" |
| 833 |
"--\n" |
| 834 |
"\n"); |
| 835 |
|
| 836 |
#define _IO__BUFFERED_TELL_METHODDEF \ |
| 837 |
{"tell", (PyCFunction)_io__Buffered_tell, METH_NOARGS, _io__Buffered_tell__doc__}, |
| 838 |
|
| 839 |
static PyObject * |
| 840 |
_io__Buffered_tell_impl(buffered *self); |
| 841 |
|
| 842 |
static PyObject * |
| 843 |
_io__Buffered_tell(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 844 |
{ |
| 845 |
PyObject *return_value = NULL; |
| 846 |
|
| 847 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 848 |
return_value = _io__Buffered_tell_impl((buffered *)self); |
| 849 |
Py_END_CRITICAL_SECTION(); |
| 850 |
|
| 851 |
return return_value; |
| 852 |
} |
| 853 |
|
| 854 |
PyDoc_STRVAR(_io__Buffered_seek__doc__, |
| 855 |
"seek($self, target, whence=0, /)\n" |
| 856 |
"--\n" |
| 857 |
"\n"); |
| 858 |
|
| 859 |
#define _IO__BUFFERED_SEEK_METHODDEF \ |
| 860 |
{"seek", _PyCFunction_CAST(_io__Buffered_seek), METH_FASTCALL, _io__Buffered_seek__doc__}, |
| 861 |
|
| 862 |
static PyObject * |
| 863 |
_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence); |
| 864 |
|
| 865 |
static PyObject * |
| 866 |
_io__Buffered_seek(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 867 |
{ |
| 868 |
PyObject *return_value = NULL; |
| 869 |
PyObject *targetobj; |
| 870 |
int whence = 0; |
| 871 |
|
| 872 |
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { |
| 873 |
goto exit; |
| 874 |
} |
| 875 |
targetobj = args[0]; |
| 876 |
if (nargs < 2) { |
| 877 |
goto skip_optional; |
| 878 |
} |
| 879 |
whence = PyLong_AsInt(args[1]); |
| 880 |
if (whence == -1 && PyErr_Occurred()) { |
| 881 |
goto exit; |
| 882 |
} |
| 883 |
skip_optional: |
| 884 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 885 |
return_value = _io__Buffered_seek_impl((buffered *)self, targetobj, whence); |
| 886 |
Py_END_CRITICAL_SECTION(); |
| 887 |
|
| 888 |
exit: |
| 889 |
return return_value; |
| 890 |
} |
| 891 |
|
| 892 |
PyDoc_STRVAR(_io__Buffered_truncate__doc__, |
| 893 |
"truncate($self, pos=None, /)\n" |
| 894 |
"--\n" |
| 895 |
"\n"); |
| 896 |
|
| 897 |
#define _IO__BUFFERED_TRUNCATE_METHODDEF \ |
| 898 |
{"truncate", _PyCFunction_CAST(_io__Buffered_truncate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__Buffered_truncate__doc__}, |
| 899 |
|
| 900 |
static PyObject * |
| 901 |
_io__Buffered_truncate_impl(buffered *self, PyTypeObject *cls, PyObject *pos); |
| 902 |
|
| 903 |
static PyObject * |
| 904 |
_io__Buffered_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 905 |
{ |
| 906 |
PyObject *return_value = NULL; |
| 907 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 908 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 909 |
#else |
| 910 |
# define KWTUPLE NULL |
| 911 |
#endif |
| 912 |
|
| 913 |
static const char * const _keywords[] = {"", NULL}; |
| 914 |
static _PyArg_Parser _parser = { |
| 915 |
.keywords = _keywords, |
| 916 |
.fname = "truncate", |
| 917 |
.kwtuple = KWTUPLE, |
| 918 |
}; |
| 919 |
#undef KWTUPLE |
| 920 |
PyObject *argsbuf[1]; |
| 921 |
PyObject *pos = Py_None; |
| 922 |
|
| 923 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 924 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 925 |
if (!args) { |
| 926 |
goto exit; |
| 927 |
} |
| 928 |
if (nargs < 1) { |
| 929 |
goto skip_optional_posonly; |
| 930 |
} |
| 931 |
pos = args[0]; |
| 932 |
skip_optional_posonly: |
| 933 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 934 |
return_value = _io__Buffered_truncate_impl((buffered *)self, cls, pos); |
| 935 |
Py_END_CRITICAL_SECTION(); |
| 936 |
|
| 937 |
exit: |
| 938 |
return return_value; |
| 939 |
} |
| 940 |
|
| 941 |
PyDoc_STRVAR(_io_BufferedReader___init____doc__, |
| 942 |
"BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n" |
| 943 |
"--\n" |
| 944 |
"\n" |
| 945 |
"Create a new buffered reader using the given readable raw IO object."); |
| 946 |
|
| 947 |
static int |
| 948 |
_io_BufferedReader___init___impl(buffered *self, PyObject *raw, |
| 949 |
Py_ssize_t buffer_size); |
| 950 |
|
| 951 |
static int |
| 952 |
_io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 953 |
{ |
| 954 |
int return_value = -1; |
| 955 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 956 |
|
| 957 |
#define NUM_KEYWORDS 2 |
| 958 |
static struct { |
| 959 |
PyGC_Head _this_is_not_used; |
| 960 |
PyObject_VAR_HEAD |
| 961 |
Py_hash_t ob_hash; |
| 962 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 963 |
} _kwtuple = { |
| 964 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 965 |
.ob_hash = -1, |
| 966 |
.ob_item = { &_Py_ID(raw), &_Py_ID(buffer_size), }, |
| 967 |
}; |
| 968 |
#undef NUM_KEYWORDS |
| 969 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 970 |
|
| 971 |
#else // !Py_BUILD_CORE |
| 972 |
# define KWTUPLE NULL |
| 973 |
#endif // !Py_BUILD_CORE |
| 974 |
|
| 975 |
static const char * const _keywords[] = {"raw", "buffer_size", NULL}; |
| 976 |
static _PyArg_Parser _parser = { |
| 977 |
.keywords = _keywords, |
| 978 |
.fname = "BufferedReader", |
| 979 |
.kwtuple = KWTUPLE, |
| 980 |
}; |
| 981 |
#undef KWTUPLE |
| 982 |
PyObject *argsbuf[2]; |
| 983 |
PyObject * const *fastargs; |
| 984 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 985 |
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
| 986 |
PyObject *raw; |
| 987 |
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; |
| 988 |
|
| 989 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 990 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 991 |
if (!fastargs) { |
| 992 |
goto exit; |
| 993 |
} |
| 994 |
raw = fastargs[0]; |
| 995 |
if (!noptargs) { |
| 996 |
goto skip_optional_pos; |
| 997 |
} |
| 998 |
{ |
| 999 |
Py_ssize_t ival = -1; |
| 1000 |
PyObject *iobj = _PyNumber_Index(fastargs[1]); |
| 1001 |
if (iobj != NULL) { |
| 1002 |
ival = PyLong_AsSsize_t(iobj); |
| 1003 |
Py_DECREF(iobj); |
| 1004 |
} |
| 1005 |
if (ival == -1 && PyErr_Occurred()) { |
| 1006 |
goto exit; |
| 1007 |
} |
| 1008 |
buffer_size = ival; |
| 1009 |
} |
| 1010 |
skip_optional_pos: |
| 1011 |
return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size); |
| 1012 |
|
| 1013 |
exit: |
| 1014 |
return return_value; |
| 1015 |
} |
| 1016 |
|
| 1017 |
PyDoc_STRVAR(_io_BufferedWriter___init____doc__, |
| 1018 |
"BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n" |
| 1019 |
"--\n" |
| 1020 |
"\n" |
| 1021 |
"A buffer for a writeable sequential RawIO object.\n" |
| 1022 |
"\n" |
| 1023 |
"The constructor creates a BufferedWriter for the given writeable raw\n" |
| 1024 |
"stream. If the buffer_size is not given, it defaults to\n" |
| 1025 |
"DEFAULT_BUFFER_SIZE."); |
| 1026 |
|
| 1027 |
static int |
| 1028 |
_io_BufferedWriter___init___impl(buffered *self, PyObject *raw, |
| 1029 |
Py_ssize_t buffer_size); |
| 1030 |
|
| 1031 |
static int |
| 1032 |
_io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 1033 |
{ |
| 1034 |
int return_value = -1; |
| 1035 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1036 |
|
| 1037 |
#define NUM_KEYWORDS 2 |
| 1038 |
static struct { |
| 1039 |
PyGC_Head _this_is_not_used; |
| 1040 |
PyObject_VAR_HEAD |
| 1041 |
Py_hash_t ob_hash; |
| 1042 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1043 |
} _kwtuple = { |
| 1044 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1045 |
.ob_hash = -1, |
| 1046 |
.ob_item = { &_Py_ID(raw), &_Py_ID(buffer_size), }, |
| 1047 |
}; |
| 1048 |
#undef NUM_KEYWORDS |
| 1049 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1050 |
|
| 1051 |
#else // !Py_BUILD_CORE |
| 1052 |
# define KWTUPLE NULL |
| 1053 |
#endif // !Py_BUILD_CORE |
| 1054 |
|
| 1055 |
static const char * const _keywords[] = {"raw", "buffer_size", NULL}; |
| 1056 |
static _PyArg_Parser _parser = { |
| 1057 |
.keywords = _keywords, |
| 1058 |
.fname = "BufferedWriter", |
| 1059 |
.kwtuple = KWTUPLE, |
| 1060 |
}; |
| 1061 |
#undef KWTUPLE |
| 1062 |
PyObject *argsbuf[2]; |
| 1063 |
PyObject * const *fastargs; |
| 1064 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 1065 |
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
| 1066 |
PyObject *raw; |
| 1067 |
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; |
| 1068 |
|
| 1069 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 1070 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1071 |
if (!fastargs) { |
| 1072 |
goto exit; |
| 1073 |
} |
| 1074 |
raw = fastargs[0]; |
| 1075 |
if (!noptargs) { |
| 1076 |
goto skip_optional_pos; |
| 1077 |
} |
| 1078 |
{ |
| 1079 |
Py_ssize_t ival = -1; |
| 1080 |
PyObject *iobj = _PyNumber_Index(fastargs[1]); |
| 1081 |
if (iobj != NULL) { |
| 1082 |
ival = PyLong_AsSsize_t(iobj); |
| 1083 |
Py_DECREF(iobj); |
| 1084 |
} |
| 1085 |
if (ival == -1 && PyErr_Occurred()) { |
| 1086 |
goto exit; |
| 1087 |
} |
| 1088 |
buffer_size = ival; |
| 1089 |
} |
| 1090 |
skip_optional_pos: |
| 1091 |
return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size); |
| 1092 |
|
| 1093 |
exit: |
| 1094 |
return return_value; |
| 1095 |
} |
| 1096 |
|
| 1097 |
PyDoc_STRVAR(_io_BufferedWriter_write__doc__, |
| 1098 |
"write($self, buffer, /)\n" |
| 1099 |
"--\n" |
| 1100 |
"\n"); |
| 1101 |
|
| 1102 |
#define _IO_BUFFEREDWRITER_WRITE_METHODDEF \ |
| 1103 |
{"write", (PyCFunction)_io_BufferedWriter_write, METH_O, _io_BufferedWriter_write__doc__}, |
| 1104 |
|
| 1105 |
static PyObject * |
| 1106 |
_io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer); |
| 1107 |
|
| 1108 |
static PyObject * |
| 1109 |
_io_BufferedWriter_write(PyObject *self, PyObject *arg) |
| 1110 |
{ |
| 1111 |
PyObject *return_value = NULL; |
| 1112 |
Py_buffer buffer = {NULL, NULL}; |
| 1113 |
|
| 1114 |
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { |
| 1115 |
goto exit; |
| 1116 |
} |
| 1117 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 1118 |
return_value = _io_BufferedWriter_write_impl((buffered *)self, &buffer); |
| 1119 |
Py_END_CRITICAL_SECTION(); |
| 1120 |
|
| 1121 |
exit: |
| 1122 |
/* Cleanup for buffer */ |
| 1123 |
if (buffer.obj) { |
| 1124 |
PyBuffer_Release(&buffer); |
| 1125 |
} |
| 1126 |
|
| 1127 |
return return_value; |
| 1128 |
} |
| 1129 |
|
| 1130 |
PyDoc_STRVAR(_io_BufferedRWPair___init____doc__, |
| 1131 |
"BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE, /)\n" |
| 1132 |
"--\n" |
| 1133 |
"\n" |
| 1134 |
"A buffered reader and writer object together.\n" |
| 1135 |
"\n" |
| 1136 |
"A buffered reader object and buffered writer object put together to\n" |
| 1137 |
"form a sequential IO object that can read and write. This is typically\n" |
| 1138 |
"used with a socket or two-way pipe.\n" |
| 1139 |
"\n" |
| 1140 |
"reader and writer are RawIOBase objects that are readable and\n" |
| 1141 |
"writeable respectively. If the buffer_size is omitted it defaults to\n" |
| 1142 |
"DEFAULT_BUFFER_SIZE."); |
| 1143 |
|
| 1144 |
static int |
| 1145 |
_io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader, |
| 1146 |
PyObject *writer, Py_ssize_t buffer_size); |
| 1147 |
|
| 1148 |
static int |
| 1149 |
_io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 1150 |
{ |
| 1151 |
int return_value = -1; |
| 1152 |
PyTypeObject *base_tp = clinic_state()->PyBufferedRWPair_Type; |
| 1153 |
PyObject *reader; |
| 1154 |
PyObject *writer; |
| 1155 |
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; |
| 1156 |
|
| 1157 |
if ((Py_IS_TYPE(self, base_tp) || |
| 1158 |
Py_TYPE(self)->tp_new == base_tp->tp_new) && |
| 1159 |
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) { |
| 1160 |
goto exit; |
| 1161 |
} |
| 1162 |
if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) { |
| 1163 |
goto exit; |
| 1164 |
} |
| 1165 |
reader = PyTuple_GET_ITEM(args, 0); |
| 1166 |
writer = PyTuple_GET_ITEM(args, 1); |
| 1167 |
if (PyTuple_GET_SIZE(args) < 3) { |
| 1168 |
goto skip_optional; |
| 1169 |
} |
| 1170 |
{ |
| 1171 |
Py_ssize_t ival = -1; |
| 1172 |
PyObject *iobj = _PyNumber_Index(PyTuple_GET_ITEM(args, 2)); |
| 1173 |
if (iobj != NULL) { |
| 1174 |
ival = PyLong_AsSsize_t(iobj); |
| 1175 |
Py_DECREF(iobj); |
| 1176 |
} |
| 1177 |
if (ival == -1 && PyErr_Occurred()) { |
| 1178 |
goto exit; |
| 1179 |
} |
| 1180 |
buffer_size = ival; |
| 1181 |
} |
| 1182 |
skip_optional: |
| 1183 |
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size); |
| 1184 |
|
| 1185 |
exit: |
| 1186 |
return return_value; |
| 1187 |
} |
| 1188 |
|
| 1189 |
PyDoc_STRVAR(_io_BufferedRandom___init____doc__, |
| 1190 |
"BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n" |
| 1191 |
"--\n" |
| 1192 |
"\n" |
| 1193 |
"A buffered interface to random access streams.\n" |
| 1194 |
"\n" |
| 1195 |
"The constructor creates a reader and writer for a seekable stream,\n" |
| 1196 |
"raw, given in the first argument. If the buffer_size is omitted it\n" |
| 1197 |
"defaults to DEFAULT_BUFFER_SIZE."); |
| 1198 |
|
| 1199 |
static int |
| 1200 |
_io_BufferedRandom___init___impl(buffered *self, PyObject *raw, |
| 1201 |
Py_ssize_t buffer_size); |
| 1202 |
|
| 1203 |
static int |
| 1204 |
_io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 1205 |
{ |
| 1206 |
int return_value = -1; |
| 1207 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1208 |
|
| 1209 |
#define NUM_KEYWORDS 2 |
| 1210 |
static struct { |
| 1211 |
PyGC_Head _this_is_not_used; |
| 1212 |
PyObject_VAR_HEAD |
| 1213 |
Py_hash_t ob_hash; |
| 1214 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1215 |
} _kwtuple = { |
| 1216 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1217 |
.ob_hash = -1, |
| 1218 |
.ob_item = { &_Py_ID(raw), &_Py_ID(buffer_size), }, |
| 1219 |
}; |
| 1220 |
#undef NUM_KEYWORDS |
| 1221 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1222 |
|
| 1223 |
#else // !Py_BUILD_CORE |
| 1224 |
# define KWTUPLE NULL |
| 1225 |
#endif // !Py_BUILD_CORE |
| 1226 |
|
| 1227 |
static const char * const _keywords[] = {"raw", "buffer_size", NULL}; |
| 1228 |
static _PyArg_Parser _parser = { |
| 1229 |
.keywords = _keywords, |
| 1230 |
.fname = "BufferedRandom", |
| 1231 |
.kwtuple = KWTUPLE, |
| 1232 |
}; |
| 1233 |
#undef KWTUPLE |
| 1234 |
PyObject *argsbuf[2]; |
| 1235 |
PyObject * const *fastargs; |
| 1236 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 1237 |
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
| 1238 |
PyObject *raw; |
| 1239 |
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; |
| 1240 |
|
| 1241 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 1242 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1243 |
if (!fastargs) { |
| 1244 |
goto exit; |
| 1245 |
} |
| 1246 |
raw = fastargs[0]; |
| 1247 |
if (!noptargs) { |
| 1248 |
goto skip_optional_pos; |
| 1249 |
} |
| 1250 |
{ |
| 1251 |
Py_ssize_t ival = -1; |
| 1252 |
PyObject *iobj = _PyNumber_Index(fastargs[1]); |
| 1253 |
if (iobj != NULL) { |
| 1254 |
ival = PyLong_AsSsize_t(iobj); |
| 1255 |
Py_DECREF(iobj); |
| 1256 |
} |
| 1257 |
if (ival == -1 && PyErr_Occurred()) { |
| 1258 |
goto exit; |
| 1259 |
} |
| 1260 |
buffer_size = ival; |
| 1261 |
} |
| 1262 |
skip_optional_pos: |
| 1263 |
return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size); |
| 1264 |
|
| 1265 |
exit: |
| 1266 |
return return_value; |
| 1267 |
} |
| 1268 |
/*[clinic end generated code: output=3ee17211d2010462 input=a9049054013a1b77]*/ |