diff options
Diffstat (limited to 'Modules/_io/clinic/iobase.c.h')
-rw-r--r-- | Modules/_io/clinic/iobase.c.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index 68eaadd..a5c8eea 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -185,10 +185,16 @@ _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t limit = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _Py_convert_optional_to_ssize_t, &limit)) { + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) { + goto exit; + } +skip_optional: return_value = _io__IOBase_readline_impl(self, limit); exit: @@ -217,10 +223,16 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t hint = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readlines", - _Py_convert_optional_to_ssize_t, &hint)) { + if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) { goto exit; } +skip_optional: return_value = _io__IOBase_readlines_impl(self, hint); exit: @@ -252,10 +264,30 @@ _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_ParseStack(args, nargs, "|n:read", - &n)) { + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } + if (nargs < 1) { + goto skip_optional; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + n = ival; + } +skip_optional: return_value = _io__RawIOBase_read_impl(self, n); exit: @@ -279,4 +311,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=cde4b0e96a4e69e3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=60e43a7cbd9f314e input=a9049054013a1b77]*/ |