summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-30 06:15:31 (GMT)
committerGitHub <noreply@github.com>2017-03-30 06:15:31 (GMT)
commit762bf40438a572a398e500c74e38f9894ea20a45 (patch)
treee3cec204dd4f633631650bf10222344a2c605929 /Modules/_io/clinic
parentea720fe7e99d68924deab38de955fe97f87e2b29 (diff)
downloadcpython-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')
-rw-r--r--Modules/_io/clinic/bufferedio.c.h6
-rw-r--r--Modules/_io/clinic/bytesio.c.h19
-rw-r--r--Modules/_io/clinic/fileio.c.h4
-rw-r--r--Modules/_io/clinic/iobase.c.h6
-rw-r--r--Modules/_io/clinic/stringio.c.h17
-rw-r--r--Modules/_io/clinic/textio.c.h4
-rw-r--r--Modules/_io/clinic/winconsoleio.c.h4
7 files changed, 29 insertions, 31 deletions
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index 4337ecf..c910dce 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -134,7 +134,7 @@ _io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *
Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _PyIO_ConvertSsize_t, &n)) {
+ _Py_convert_optional_to_ssize_t, &n)) {
goto exit;
}
@@ -258,7 +258,7 @@ _io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs, PyObje
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;
}
@@ -500,4 +500,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=e37b969b1acaa09c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3cf3262c9b157dc1 input=a9049054013a1b77]*/
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]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index 7a8e2c6..cd5075d 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -214,7 +214,7 @@ _io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnam
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;
}
@@ -385,4 +385,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=034d782a0daa82bd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a4044e2d878248d0 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h
index 045bb3b..a6780c2 100644
--- a/Modules/_io/clinic/iobase.c.h
+++ b/Modules/_io/clinic/iobase.c.h
@@ -186,7 +186,7 @@ _io__IOBase_readline(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject
Py_ssize_t limit = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
- _PyIO_ConvertSsize_t, &limit)) {
+ _Py_convert_optional_to_ssize_t, &limit)) {
goto exit;
}
@@ -222,7 +222,7 @@ _io__IOBase_readlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObjec
Py_ssize_t hint = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readlines",
- _PyIO_ConvertSsize_t, &hint)) {
+ _Py_convert_optional_to_ssize_t, &hint)) {
goto exit;
}
@@ -291,4 +291,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
-/*[clinic end generated code: output=1bcece367fc7b0cd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d3f59c135231baae input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
index 362d0b9..2710135 100644
--- a/Modules/_io/clinic/stringio.c.h
+++ b/Modules/_io/clinic/stringio.c.h
@@ -60,7 +60,7 @@ _io_StringIO_read(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *k
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;
}
@@ -94,7 +94,7 @@ _io_StringIO_readline(stringio *self, PyObject **args, Py_ssize_t nargs, PyObjec
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;
}
@@ -121,24 +121,23 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc__,
{"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__},
static PyObject *
-_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
+_io_StringIO_truncate_impl(stringio *self, Py_ssize_t size);
static PyObject *
_io_StringIO_truncate(stringio *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_StringIO_truncate_impl(self, arg);
+ return_value = _io_StringIO_truncate_impl(self, size);
exit:
return return_value;
@@ -303,4 +302,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=965fe9cb0d11511a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=03429d95ed7cd92f input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index 46b3eda..4eab136 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -237,7 +237,7 @@ _io_TextIOWrapper_read(textio *self, PyObject **args, Py_ssize_t nargs, PyObject
Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read",
- _PyIO_ConvertSsize_t, &n)) {
+ _Py_convert_optional_to_ssize_t, &n)) {
goto exit;
}
@@ -480,4 +480,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=67eba50449900a96 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8e5c21c88c7c70bc input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h
index f568053..f694cd8 100644
--- a/Modules/_io/clinic/winconsoleio.c.h
+++ b/Modules/_io/clinic/winconsoleio.c.h
@@ -221,7 +221,7 @@ _io__WindowsConsoleIO_read(winconsoleio *self, PyObject **args, Py_ssize_t nargs
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;
}
@@ -332,4 +332,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
-/*[clinic end generated code: output=04dab03363f5e304 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f2a240ec6af12a20 input=a9049054013a1b77]*/