summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic/textio.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io/clinic/textio.c.h')
-rw-r--r--Modules/_io/clinic/textio.c.h55
1 files changed, 47 insertions, 8 deletions
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index f056416e..0ff0324 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -251,7 +251,7 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
PyObject *text;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("write", "str", arg);
+ _PyArg_BadArgument("write", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -281,10 +281,16 @@ _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
- if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _Py_convert_optional_to_ssize_t, &n)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
+ goto exit;
+ }
+skip_optional:
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
@@ -308,10 +314,30 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs
PyObject *return_value = NULL;
Py_ssize_t size = -1;
- if (!_PyArg_ParseStack(args, nargs, "|n:readline",
- &size)) {
+ if (!_PyArg_CheckPositional("readline", 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;
+ }
+ size = ival;
+ }
+skip_optional:
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
@@ -336,10 +362,23 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *cookieObj;
int whence = 0;
- if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
- &cookieObj, &whence)) {
+ if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
+ goto exit;
+ }
+ cookieObj = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ whence = _PyLong_AsInt(args[1]);
+ if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional:
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
@@ -509,4 +548,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8bdd1035bf878d6f input=a9049054013a1b77]*/