|
|
|
@ -8,13 +8,6 @@ class _io.BytesIO "bytesio *" "&PyBytesIO_Type" |
|
|
|
[clinic start generated code]*/ |
|
|
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7f50ec034f5c0b26]*/ |
|
|
|
|
|
|
|
/*[python input] |
|
|
|
class io_ssize_t_converter(CConverter): |
|
|
|
type = 'Py_ssize_t' |
|
|
|
converter = '_PyIO_ConvertSsize_t' |
|
|
|
[python start generated code]*/ |
|
|
|
/*[python end generated code: output=da39a3ee5e6b4b0d input=d0a811d3cbfd1b33]*/ |
|
|
|
|
|
|
|
typedef struct { |
|
|
|
PyObject_HEAD |
|
|
|
PyObject *buf; |
|
|
|
@ -381,7 +374,7 @@ read_bytes(bytesio *self, Py_ssize_t size) |
|
|
|
|
|
|
|
/*[clinic input] |
|
|
|
_io.BytesIO.read |
|
|
|
size: io_ssize_t = -1 |
|
|
|
size: Py_ssize_t(accept={int, NoneType}) = -1 |
|
|
|
/ |
|
|
|
|
|
|
|
Read at most size bytes, returned as a bytes object. |
|
|
|
@ -392,7 +385,7 @@ Return an empty bytes object at EOF. |
|
|
|
|
|
|
|
static PyObject * |
|
|
|
_io_BytesIO_read_impl(bytesio *self, Py_ssize_t size) |
|
|
|
/*[clinic end generated code: output=9cc025f21c75bdd2 input=c81ec53b8f2cc3cf]*/ |
|
|
|
/*[clinic end generated code: output=9cc025f21c75bdd2 input=74344a39f431c3d7]*/ |
|
|
|
{ |
|
|
|
Py_ssize_t n; |
|
|
|
|
|
|
|
@ -412,7 +405,7 @@ _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size) |
|
|
|
|
|
|
|
/*[clinic input] |
|
|
|
_io.BytesIO.read1 |
|
|
|
size: io_ssize_t = -1 |
|
|
|
size: Py_ssize_t(accept={int, NoneType}) = -1 |
|
|
|
/ |
|
|
|
|
|
|
|
Read at most size bytes, returned as a bytes object. |
|
|
|
@ -423,14 +416,14 @@ Return an empty bytes object at EOF. |
|
|
|
|
|
|
|
static PyObject * |
|
|
|
_io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size) |
|
|
|
/*[clinic end generated code: output=d0f843285aa95f1c input=67cf18b142111664]*/ |
|
|
|
/*[clinic end generated code: output=d0f843285aa95f1c input=440a395bf9129ef5]*/ |
|
|
|
{ |
|
|
|
return _io_BytesIO_read_impl(self, size); |
|
|
|
} |
|
|
|
|
|
|
|
/*[clinic input] |
|
|
|
_io.BytesIO.readline |
|
|
|
size: io_ssize_t = -1 |
|
|
|
size: Py_ssize_t(accept={int, NoneType}) = -1 |
|
|
|
/ |
|
|
|
|
|
|
|
Next line from the file, as a bytes object. |
|
|
|
@ -442,7 +435,7 @@ Return an empty bytes object at EOF. |
|
|
|
|
|
|
|
static PyObject * |
|
|
|
_io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size) |
|
|
|
/*[clinic end generated code: output=4bff3c251df8ffcd input=7c95bd3f9e9d1646]*/ |
|
|
|
/*[clinic end generated code: output=4bff3c251df8ffcd input=e7c3fbd1744e2783]*/ |
|
|
|
{ |
|
|
|
Py_ssize_t n; |
|
|
|
|
|
|
|
@ -556,7 +549,7 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer) |
|
|
|
|
|
|
|
/*[clinic input] |
|
|
|
_io.BytesIO.truncate |
|
|
|
size as arg: object = None |
|
|
|
size: Py_ssize_t(accept={int, NoneType}, c_default="self->pos") = None |
|
|
|
/ |
|
|
|
|
|
|
|
Truncate the file to at most size bytes. |
|
|
|
@ -566,31 +559,12 @@ The current file position is unchanged. Returns the new size. |
|
|
|
[clinic start generated code]*/ |
|
|
|
|
|
|
|
static PyObject * |
|
|
|
_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg) |
|
|
|
/*[clinic end generated code: output=81e6be60e67ddd66 input=11ed1966835462ba]*/ |
|
|
|
_io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size) |
|
|
|
/*[clinic end generated code: output=9ad17650c15fa09b input=423759dd42d2f7c1]*/ |
|
|
|
{ |
|
|
|
Py_ssize_t size; |
|
|
|
|
|
|
|
CHECK_CLOSED(self); |
|
|
|
CHECK_EXPORTS(self); |
|
|
|
|
|
|
|
if (arg == Py_None) { |
|
|
|
/* Truncate to current position if no argument is passed. */ |
|
|
|
size = self->pos; |
|
|
|
} |
|
|
|
else if (PyIndex_Check(arg)) { |
|
|
|
size = PyNumber_AsSsize_t(arg, PyExc_OverflowError); |
|
|
|
if (size == -1 && PyErr_Occurred()) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
PyErr_Format(PyExc_TypeError, |
|
|
|
"argument should be integer or None, not '%.200s'", |
|
|
|
Py_TYPE(arg)->tp_name); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
if (size < 0) { |
|
|
|
PyErr_Format(PyExc_ValueError, |
|
|
|
"negative size value %zd", size); |
|
|
|
|