summaryrefslogtreecommitdiff
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:08:17 +0100
committerNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:08:17 +0100
commitc6180bb73c8c7c7f9d8ea9816487b710597b6fc1 (patch)
treefb4a5c18886537b4b7df46ed3b2aa579747ff507 /Modules/_io/clinic
parent5e0114a832a903518c4af6983161c0c2a8942a24 (diff)
parent819a21a3a4aac38f32e1ba4f68bcef45591fa3f0 (diff)
downloadcpython-c6180bb73c8c7c7f9d8ea9816487b710597b6fc1.tar.gz
Merge issue #26355 fix from Python 3.5
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r--Modules/_io/clinic/_iomodule.c.h14
-rw-r--r--Modules/_io/clinic/bufferedio.c.h80
-rw-r--r--Modules/_io/clinic/bytesio.c.h31
-rw-r--r--Modules/_io/clinic/fileio.c.h31
-rw-r--r--Modules/_io/clinic/iobase.c.h11
-rw-r--r--Modules/_io/clinic/stringio.c.h22
-rw-r--r--Modules/_io/clinic/textio.c.h45
-rw-r--r--Modules/_io/clinic/winconsoleio.c.h331
8 files changed, 480 insertions, 85 deletions
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index 6c88e32e5a..f2e91a9fe6 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -127,7 +127,7 @@ PyDoc_STRVAR(_io_open__doc__,
"opened in a binary mode.");
#define _IO_OPEN_METHODDEF \
- {"open", (PyCFunction)_io_open, METH_VARARGS|METH_KEYWORDS, _io_open__doc__},
+ {"open", (PyCFunction)_io_open, METH_FASTCALL, _io_open__doc__},
static PyObject *
_io_open_impl(PyObject *module, PyObject *file, const char *mode,
@@ -135,10 +135,11 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
const char *newline, int closefd, PyObject *opener);
static PyObject *
-_io_open(PyObject *module, PyObject *args, PyObject *kwargs)
+_io_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
- static char *_keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
+ static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
+ static _PyArg_Parser _parser = {"O|sizzziO:open", _keywords, 0};
PyObject *file;
const char *mode = "r";
int buffering = -1;
@@ -148,12 +149,13 @@ _io_open(PyObject *module, PyObject *args, PyObject *kwargs)
int closefd = 1;
PyObject *opener = Py_None;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sizzziO:open", _keywords,
- &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener))
+ if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) {
goto exit;
+ }
return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener);
exit:
return return_value;
}
-/*[clinic end generated code: output=bc2c003cb7daeafe input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c5b8fc8b83102bbf input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index 437e275730..58144a4015 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -19,14 +19,16 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -48,14 +50,16 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto1", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
+ }
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -99,8 +103,9 @@ _io__Buffered_peek(buffered *self, PyObject *args)
Py_ssize_t size = 0;
if (!PyArg_ParseTuple(args, "|n:peek",
- &size))
+ &size)) {
goto exit;
+ }
return_value = _io__Buffered_peek_impl(self, size);
exit:
@@ -125,8 +130,9 @@ _io__Buffered_read(buffered *self, PyObject *args)
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &n))
+ _PyIO_ConvertSsize_t, &n)) {
goto exit;
+ }
return_value = _io__Buffered_read_impl(self, n);
exit:
@@ -150,8 +156,9 @@ _io__Buffered_read1(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_ssize_t n;
- if (!PyArg_Parse(arg, "n:read1", &n))
+ if (!PyArg_Parse(arg, "n:read1", &n)) {
goto exit;
+ }
return_value = _io__Buffered_read1_impl(self, n);
exit:
@@ -175,14 +182,16 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io__Buffered_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -204,14 +213,16 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto1", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
+ }
return_value = _io__Buffered_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -234,8 +245,9 @@ _io__Buffered_readline(buffered *self, PyObject *args)
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
- _PyIO_ConvertSsize_t, &size))
+ _PyIO_ConvertSsize_t, &size)) {
goto exit;
+ }
return_value = _io__Buffered_readline_impl(self, size);
exit:
@@ -261,8 +273,9 @@ _io__Buffered_seek(buffered *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &targetobj, &whence))
+ &targetobj, &whence)) {
goto exit;
+ }
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit:
@@ -288,8 +301,9 @@ _io__Buffered_truncate(buffered *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &pos))
+ &pos)) {
goto exit;
+ }
return_value = _io__Buffered_truncate_impl(self, pos);
exit:
@@ -310,13 +324,15 @@ static int
_io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedReader", _keywords,
- &raw, &buffer_size))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
exit:
@@ -341,13 +357,15 @@ static int
_io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedWriter", _keywords,
- &raw, &buffer_size))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
exit:
@@ -371,14 +389,16 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &buffer))
+ if (!PyArg_Parse(arg, "y*:write", &buffer)) {
goto exit;
+ }
return_value = _io_BufferedWriter_write_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -410,11 +430,13 @@ _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
- !_PyArg_NoKeywords("BufferedRWPair", kwargs))
+ !_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
+ }
if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
- &reader, &writer, &buffer_size))
+ &reader, &writer, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit:
@@ -439,16 +461,18 @@ static int
_io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedRandom", _keywords,
- &raw, &buffer_size))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
exit:
return return_value;
}
-/*[clinic end generated code: output=2bbb5e239b4ffe6f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a956f394ecde4cf9 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 5f2abb03a7..c64ce5c77c 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -171,8 +171,9 @@ _io_BytesIO_read(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_read_impl(self, arg);
exit:
@@ -215,8 +216,9 @@ _io_BytesIO_readline(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readline_impl(self, arg);
exit:
@@ -247,8 +249,9 @@ _io_BytesIO_readlines(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "readlines",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readlines_impl(self, arg);
exit:
@@ -276,14 +279,16 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io_BytesIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -311,8 +316,9 @@ _io_BytesIO_truncate(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_truncate_impl(self, arg);
exit:
@@ -345,8 +351,9 @@ _io_BytesIO_seek(bytesio *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
@@ -408,15 +415,17 @@ static int
_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"initial_bytes", NULL};
+ static const char * const _keywords[] = {"initial_bytes", NULL};
+ static _PyArg_Parser _parser = {"|O:BytesIO", _keywords, 0};
PyObject *initvalue = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords,
- &initvalue))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &initvalue)) {
goto exit;
+ }
return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
exit:
return return_value;
}
-/*[clinic end generated code: output=60ce2c6272718431 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6382e8eb578eea64 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index 10420082ac..908fe0f8c8 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -49,15 +49,17 @@ static int
_io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ static _PyArg_Parser _parser = {"O|siO:FileIO", _keywords, 0};
PyObject *nameobj;
const char *mode = "r";
int closefd = 1;
PyObject *opener = Py_None;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|siO:FileIO", _keywords,
- &nameobj, &mode, &closefd, &opener))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &nameobj, &mode, &closefd, &opener)) {
goto exit;
+ }
return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener);
exit:
@@ -154,14 +156,16 @@ _io_FileIO_readinto(fileio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io_FileIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -210,8 +214,9 @@ _io_FileIO_read(fileio *self, PyObject *args)
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &size))
+ _PyIO_ConvertSsize_t, &size)) {
goto exit;
+ }
return_value = _io_FileIO_read_impl(self, size);
exit:
@@ -240,14 +245,16 @@ _io_FileIO_write(fileio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &b))
+ if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
+ }
return_value = _io_FileIO_write_impl(self, &b);
exit:
/* Cleanup for b */
- if (b.obj)
+ if (b.obj) {
PyBuffer_Release(&b);
+ }
return return_value;
}
@@ -280,8 +287,9 @@ _io_FileIO_seek(fileio *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_FileIO_seek_impl(self, pos, whence);
exit:
@@ -333,8 +341,9 @@ _io_FileIO_truncate(fileio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &posobj))
+ &posobj)) {
goto exit;
+ }
return_value = _io_FileIO_truncate_impl(self, posobj);
exit:
@@ -364,4 +373,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=dcbc39b466598492 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=51924bc0ee11d58e input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h
index 9762f11222..edbf73a40b 100644
--- a/Modules/_io/clinic/iobase.c.h
+++ b/Modules/_io/clinic/iobase.c.h
@@ -186,8 +186,9 @@ _io__IOBase_readline(PyObject *self, PyObject *args)
Py_ssize_t limit = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
- _PyIO_ConvertSsize_t, &limit))
+ _PyIO_ConvertSsize_t, &limit)) {
goto exit;
+ }
return_value = _io__IOBase_readline_impl(self, limit);
exit:
@@ -217,8 +218,9 @@ _io__IOBase_readlines(PyObject *self, PyObject *args)
Py_ssize_t hint = -1;
if (!PyArg_ParseTuple(args, "|O&:readlines",
- _PyIO_ConvertSsize_t, &hint))
+ _PyIO_ConvertSsize_t, &hint)) {
goto exit;
+ }
return_value = _io__IOBase_readlines_impl(self, hint);
exit:
@@ -251,8 +253,9 @@ _io__RawIOBase_read(PyObject *self, PyObject *args)
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|n:read",
- &n))
+ &n)) {
goto exit;
+ }
return_value = _io__RawIOBase_read_impl(self, n);
exit:
@@ -276,4 +279,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
-/*[clinic end generated code: output=b874952f5cc248a4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0f53fed928d8e02f input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
index a8e32a3376..d2c05d7cb1 100644
--- a/Modules/_io/clinic/stringio.c.h
+++ b/Modules/_io/clinic/stringio.c.h
@@ -61,8 +61,9 @@ _io_StringIO_read(stringio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_read_impl(self, arg);
exit:
@@ -91,8 +92,9 @@ _io_StringIO_readline(stringio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_readline_impl(self, arg);
exit:
@@ -123,8 +125,9 @@ _io_StringIO_truncate(stringio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_truncate_impl(self, arg);
exit:
@@ -157,8 +160,9 @@ _io_StringIO_seek(stringio *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_StringIO_seek_impl(self, pos, whence);
exit:
@@ -217,13 +221,15 @@ static int
_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"initial_value", "newline", NULL};
+ static const char * const _keywords[] = {"initial_value", "newline", NULL};
+ static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0};
PyObject *value = NULL;
PyObject *newline_obj = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:StringIO", _keywords,
- &value, &newline_obj))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &value, &newline_obj)) {
goto exit;
+ }
return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
exit:
@@ -283,4 +289,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=f061cf3a20cd14ed input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5dd5c2a213e75405 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index dc7e8c7584..f39c35581e 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -24,14 +24,16 @@ static int
_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"decoder", "translate", "errors", NULL};
+ static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
+ static _PyArg_Parser _parser = {"Oi|O:IncrementalNewlineDecoder", _keywords, 0};
PyObject *decoder;
int translate;
PyObject *errors = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O:IncrementalNewlineDecoder", _keywords,
- &decoder, &translate, &errors))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &decoder, &translate, &errors)) {
goto exit;
+ }
return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
exit:
@@ -44,23 +46,25 @@ PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
"\n");
#define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \
- {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_VARARGS|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__},
+ {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_FASTCALL, _io_IncrementalNewlineDecoder_decode__doc__},
static PyObject *
_io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
PyObject *input, int final);
static PyObject *
-_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *args, PyObject *kwargs)
+_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
- static char *_keywords[] = {"input", "final", NULL};
+ static const char * const _keywords[] = {"input", "final", NULL};
+ static _PyArg_Parser _parser = {"O|i:decode", _keywords, 0};
PyObject *input;
int final = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:decode", _keywords,
- &input, &final))
+ if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ &input, &final)) {
goto exit;
+ }
return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
exit:
@@ -153,7 +157,8 @@ static int
_io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
+ static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
+ static _PyArg_Parser _parser = {"O|zzzii:TextIOWrapper", _keywords, 0};
PyObject *buffer;
const char *encoding = NULL;
const char *errors = NULL;
@@ -161,9 +166,10 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
int line_buffering = 0;
int write_through = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|zzzii:TextIOWrapper", _keywords,
- &buffer, &encoding, &errors, &newline, &line_buffering, &write_through))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) {
goto exit;
+ }
return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
exit:
@@ -204,8 +210,9 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *text;
- if (!PyArg_Parse(arg, "U:write", &text))
+ if (!PyArg_Parse(arg, "U:write", &text)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_write_impl(self, text);
exit:
@@ -230,8 +237,9 @@ _io_TextIOWrapper_read(textio *self, PyObject *args)
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &n))
+ _PyIO_ConvertSsize_t, &n)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
@@ -256,8 +264,9 @@ _io_TextIOWrapper_readline(textio *self, PyObject *args)
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|n:readline",
- &size))
+ &size)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
@@ -283,8 +292,9 @@ _io_TextIOWrapper_seek(textio *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &cookieObj, &whence))
+ &cookieObj, &whence)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
@@ -327,8 +337,9 @@ _io_TextIOWrapper_truncate(textio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &pos))
+ &pos)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_truncate_impl(self, pos);
exit:
@@ -453,4 +464,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=690608f85aab8ba5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=78ad14eba1667254 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h
new file mode 100644
index 0000000000..e44fcbb7a1
--- /dev/null
+++ b/Modules/_io/clinic/winconsoleio.c.h
@@ -0,0 +1,331 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Close the handle.\n"
+"\n"
+"A closed handle cannot be used for further I/O operations. close() may be\n"
+"called more than once without error.");
+
+#define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io__WindowsConsoleIO_close, METH_NOARGS, _io__WindowsConsoleIO_close__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_close_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_close(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_close_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO___init____doc__,
+"_WindowsConsoleIO(file, mode=\'r\', closefd=True, opener=None)\n"
+"--\n"
+"\n"
+"Open a console buffer by file descriptor.\n"
+"\n"
+"The mode can be \'rb\' (default), or \'wb\' for reading or writing bytes. All\n"
+"other mode characters will be ignored. Mode \'b\' will be assumed if it is\n"
+"omitted. The *opener* parameter is always ignored.");
+
+static int
+_io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
+ const char *mode, int closefd,
+ PyObject *opener);
+
+static int
+_io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ static _PyArg_Parser _parser = {"O|siO:_WindowsConsoleIO", _keywords, 0};
+ PyObject *nameobj;
+ const char *mode = "r";
+ int closefd = 1;
+ PyObject *opener = Py_None;
+
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &nameobj, &mode, &closefd, &opener)) {
+ goto exit;
+ }
+ return_value = _io__WindowsConsoleIO___init___impl((winconsoleio *)self, nameobj, mode, closefd, opener);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_fileno__doc__,
+"fileno($self, /)\n"
+"--\n"
+"\n"
+"Return the underlying file descriptor (an integer).\n"
+"\n"
+"fileno is only set when a file descriptor is used to open\n"
+"one of the standard streams.");
+
+#define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF \
+ {"fileno", (PyCFunction)_io__WindowsConsoleIO_fileno, METH_NOARGS, _io__WindowsConsoleIO_fileno__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_fileno_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_fileno(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_fileno_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n"
+"True if console is an input buffer.");
+
+#define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io__WindowsConsoleIO_readable, METH_NOARGS, _io__WindowsConsoleIO_readable__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_readable_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_readable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_readable_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n"
+"True if console is an output buffer.");
+
+#define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io__WindowsConsoleIO_writable, METH_NOARGS, _io__WindowsConsoleIO_writable__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_writable_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_writable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_writable_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_readinto__doc__,
+"readinto($self, buffer, /)\n"
+"--\n"
+"\n"
+"Same as RawIOBase.readinto().");
+
+#define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF \
+ {"readinto", (PyCFunction)_io__WindowsConsoleIO_readinto, METH_O, _io__WindowsConsoleIO_readinto__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_readinto_impl(winconsoleio *self, Py_buffer *buffer);
+
+static PyObject *
+_io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
+ goto exit;
+ }
+ return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj) {
+ PyBuffer_Release(&buffer);
+ }
+
+ return return_value;
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_readall__doc__,
+"readall($self, /)\n"
+"--\n"
+"\n"
+"Read all data from the console, returned as bytes.\n"
+"\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF \
+ {"readall", (PyCFunction)_io__WindowsConsoleIO_readall, METH_NOARGS, _io__WindowsConsoleIO_readall__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_readall_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_readall(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_readall_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_read__doc__,
+"read($self, size=-1, /)\n"
+"--\n"
+"\n"
+"Read at most size bytes, returned as bytes.\n"
+"\n"
+"Only makes one system call when size is a positive integer,\n"
+"so less data may be returned than requested.\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO__WINDOWSCONSOLEIO_READ_METHODDEF \
+ {"read", (PyCFunction)_io__WindowsConsoleIO_read, METH_VARARGS, _io__WindowsConsoleIO_read__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_read_impl(winconsoleio *self, Py_ssize_t size);
+
+static PyObject *
+_io__WindowsConsoleIO_read(winconsoleio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t size = -1;
+
+ if (!PyArg_ParseTuple(args, "|O&:read",
+ _PyIO_ConvertSsize_t, &size)) {
+ goto exit;
+ }
+ return_value = _io__WindowsConsoleIO_read_impl(self, size);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_write__doc__,
+"write($self, b, /)\n"
+"--\n"
+"\n"
+"Write buffer b to file, return number of bytes written.\n"
+"\n"
+"Only makes one system call, so not all of the data may be written.\n"
+"The number of bytes actually written is returned.");
+
+#define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io__WindowsConsoleIO_write, METH_O, _io__WindowsConsoleIO_write__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b);
+
+static PyObject *
+_io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer b = {NULL, NULL};
+
+ if (!PyArg_Parse(arg, "y*:write", &b)) {
+ goto exit;
+ }
+ return_value = _io__WindowsConsoleIO_write_impl(self, &b);
+
+exit:
+ /* Cleanup for b */
+ if (b.obj) {
+ PyBuffer_Release(&b);
+ }
+
+ return return_value;
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#if defined(MS_WINDOWS)
+
+PyDoc_STRVAR(_io__WindowsConsoleIO_isatty__doc__,
+"isatty($self, /)\n"
+"--\n"
+"\n"
+"Always True.");
+
+#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF \
+ {"isatty", (PyCFunction)_io__WindowsConsoleIO_isatty, METH_NOARGS, _io__WindowsConsoleIO_isatty__doc__},
+
+static PyObject *
+_io__WindowsConsoleIO_isatty_impl(winconsoleio *self);
+
+static PyObject *
+_io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__WindowsConsoleIO_isatty_impl(self);
+}
+
+#endif /* defined(MS_WINDOWS) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_FILENO_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_READABLE_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_READINTO_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_READALL_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_READ_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_READ_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_READ_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITE_METHODDEF) */
+
+#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
+ #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
+#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
+/*[clinic end generated code: output=9eba916f8537fff7 input=a9049054013a1b77]*/