diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-30 06:15:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 06:15:31 (GMT) |
commit | 762bf40438a572a398e500c74e38f9894ea20a45 (patch) | |
tree | e3cec204dd4f633631650bf10222344a2c605929 /Modules/_io/clinic/bytesio.c.h | |
parent | ea720fe7e99d68924deab38de955fe97f87e2b29 (diff) | |
download | cpython-762bf40438a572a398e500c74e38f9894ea20a45.zip cpython-762bf40438a572a398e500c74e38f9894ea20a45.tar.gz cpython-762bf40438a572a398e500c74e38f9894ea20a45.tar.bz2 |
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
if pass `accept={int, NoneType}`.
Diffstat (limited to 'Modules/_io/clinic/bytesio.c.h')
-rw-r--r-- | Modules/_io/clinic/bytesio.c.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 60b7eaa..559971c 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -170,7 +170,7 @@ _io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwn Py_ssize_t size = -1; if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _PyIO_ConvertSsize_t, &size)) { + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } @@ -205,7 +205,7 @@ _io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kw Py_ssize_t size = -1; if (!_PyArg_ParseStack(args, nargs, "|O&:read1", - _PyIO_ConvertSsize_t, &size)) { + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } @@ -241,7 +241,7 @@ _io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject Py_ssize_t size = -1; if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _PyIO_ConvertSsize_t, &size)) { + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } @@ -339,24 +339,23 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__, {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, static PyObject * -_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg); +_io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size); static PyObject * _io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - PyObject *arg = Py_None; + Py_ssize_t size = self->pos; - if (!_PyArg_UnpackStack(args, nargs, "truncate", - 0, 1, - &arg)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - return_value = _io_BytesIO_truncate_impl(self, arg); + return_value = _io_BytesIO_truncate_impl(self, size); exit: return return_value; @@ -469,4 +468,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=74a856733a5d55b0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=733795434f838b71 input=a9049054013a1b77]*/ |