summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-16 08:19:43 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-16 08:19:43 (GMT)
commitf24131ff3125e59ca779d0e2fcec4967d50f950c (patch)
treec870dd7568c6bdf0b8340e282ced5205c71ee618 /Modules/_io/clinic
parent7f90cba7f3f2ebd7eb5e614917014760f61c6ec8 (diff)
downloadcpython-f24131ff3125e59ca779d0e2fcec4967d50f950c.zip
cpython-f24131ff3125e59ca779d0e2fcec4967d50f950c.tar.gz
cpython-f24131ff3125e59ca779d0e2fcec4967d50f950c.tar.bz2
Issue #20175: Converted the _io module to Argument Clinic.
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r--Modules/_io/clinic/_iomodule.c.h160
-rw-r--r--Modules/_io/clinic/bufferedio.c.h474
-rw-r--r--Modules/_io/clinic/bytesio.c.h426
-rw-r--r--Modules/_io/clinic/fileio.c.h374
-rw-r--r--Modules/_io/clinic/iobase.c.h282
-rw-r--r--Modules/_io/clinic/stringio.c.h288
-rw-r--r--Modules/_io/clinic/textio.c.h464
7 files changed, 2468 insertions, 0 deletions
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
new file mode 100644
index 0000000..df877a5
--- /dev/null
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -0,0 +1,160 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io_open__doc__,
+"open($module, /, file, mode=\'r\', buffering=-1, encoding=None,\n"
+" errors=None, newline=None, closefd=True, opener=None)\n"
+"--\n"
+"\n"
+"Open file and return a stream. Raise IOError upon failure.\n"
+"\n"
+"file is either a text or byte string giving the name (and the path\n"
+"if the file isn\'t in the current working directory) of the file to\n"
+"be opened or an integer file descriptor of the file to be\n"
+"wrapped. (If a file descriptor is given, it is closed when the\n"
+"returned I/O object is closed, unless closefd is set to False.)\n"
+"\n"
+"mode is an optional string that specifies the mode in which the file\n"
+"is opened. It defaults to \'r\' which means open for reading in text\n"
+"mode. Other common values are \'w\' for writing (truncating the file if\n"
+"it already exists), \'x\' for creating and writing to a new file, and\n"
+"\'a\' for appending (which on some Unix systems, means that all writes\n"
+"append to the end of the file regardless of the current seek position).\n"
+"In text mode, if encoding is not specified the encoding used is platform\n"
+"dependent: locale.getpreferredencoding(False) is called to get the\n"
+"current locale encoding. (For reading and writing raw bytes use binary\n"
+"mode and leave encoding unspecified.) The available modes are:\n"
+"\n"
+"========= ===============================================================\n"
+"Character Meaning\n"
+"--------- ---------------------------------------------------------------\n"
+"\'r\' open for reading (default)\n"
+"\'w\' open for writing, truncating the file first\n"
+"\'x\' create a new file and open it for writing\n"
+"\'a\' open for writing, appending to the end of the file if it exists\n"
+"\'b\' binary mode\n"
+"\'t\' text mode (default)\n"
+"\'+\' open a disk file for updating (reading and writing)\n"
+"\'U\' universal newline mode (deprecated)\n"
+"========= ===============================================================\n"
+"\n"
+"The default mode is \'rt\' (open for reading text). For binary random\n"
+"access, the mode \'w+b\' opens and truncates the file to 0 bytes, while\n"
+"\'r+b\' opens the file without truncation. The \'x\' mode implies \'w\' and\n"
+"raises an `FileExistsError` if the file already exists.\n"
+"\n"
+"Python distinguishes between files opened in binary and text modes,\n"
+"even when the underlying operating system doesn\'t. Files opened in\n"
+"binary mode (appending \'b\' to the mode argument) return contents as\n"
+"bytes objects without any decoding. In text mode (the default, or when\n"
+"\'t\' is appended to the mode argument), the contents of the file are\n"
+"returned as strings, the bytes having been first decoded using a\n"
+"platform-dependent encoding or using the specified encoding if given.\n"
+"\n"
+"\'U\' mode is deprecated and will raise an exception in future versions\n"
+"of Python. It has no effect in Python 3. Use newline to control\n"
+"universal newlines mode.\n"
+"\n"
+"buffering is an optional integer used to set the buffering policy.\n"
+"Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
+"line buffering (only usable in text mode), and an integer > 1 to indicate\n"
+"the size of a fixed-size chunk buffer. When no buffering argument is\n"
+"given, the default buffering policy works as follows:\n"
+"\n"
+"* Binary files are buffered in fixed-size chunks; the size of the buffer\n"
+" is chosen using a heuristic trying to determine the underlying device\'s\n"
+" \"block size\" and falling back on `io.DEFAULT_BUFFER_SIZE`.\n"
+" On many systems, the buffer will typically be 4096 or 8192 bytes long.\n"
+"\n"
+"* \"Interactive\" text files (files for which isatty() returns True)\n"
+" use line buffering. Other text files use the policy described above\n"
+" for binary files.\n"
+"\n"
+"encoding is the name of the encoding used to decode or encode the\n"
+"file. This should only be used in text mode. The default encoding is\n"
+"platform dependent, but any encoding supported by Python can be\n"
+"passed. See the codecs module for the list of supported encodings.\n"
+"\n"
+"errors is an optional string that specifies how encoding errors are to\n"
+"be handled---this argument should not be used in binary mode. Pass\n"
+"\'strict\' to raise a ValueError exception if there is an encoding error\n"
+"(the default of None has the same effect), or pass \'ignore\' to ignore\n"
+"errors. (Note that ignoring encoding errors can lead to data loss.)\n"
+"See the documentation for codecs.register or run \'help(codecs.Codec)\'\n"
+"for a list of the permitted encoding error strings.\n"
+"\n"
+"newline controls how universal newlines works (it only applies to text\n"
+"mode). It can be None, \'\', \'\\n\', \'\\r\', and \'\\r\\n\'. It works as\n"
+"follows:\n"
+"\n"
+"* On input, if newline is None, universal newlines mode is\n"
+" enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
+" these are translated into \'\\n\' before being returned to the\n"
+" caller. If it is \'\', universal newline mode is enabled, but line\n"
+" endings are returned to the caller untranslated. If it has any of\n"
+" the other legal values, input lines are only terminated by the given\n"
+" string, and the line ending is returned to the caller untranslated.\n"
+"\n"
+"* On output, if newline is None, any \'\\n\' characters written are\n"
+" translated to the system default line separator, os.linesep. If\n"
+" newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
+" of the other legal values, any \'\\n\' characters written are translated\n"
+" to the given string.\n"
+"\n"
+"If closefd is False, the underlying file descriptor will be kept open\n"
+"when the file is closed. This does not work when a file name is given\n"
+"and must be True in that case.\n"
+"\n"
+"A custom opener can be used by passing a callable as *opener*. The\n"
+"underlying file descriptor for the file object is then obtained by\n"
+"calling *opener* with (*file*, *flags*). *opener* must return an open\n"
+"file descriptor (passing os.open as *opener* results in functionality\n"
+"similar to passing None).\n"
+"\n"
+"open() returns a file object whose type depends on the mode, and\n"
+"through which the standard file operations such as reading and writing\n"
+"are performed. When open() is used to open a file in a text mode (\'w\',\n"
+"\'r\', \'wt\', \'rt\', etc.), it returns a TextIOWrapper. When used to open\n"
+"a file in a binary mode, the returned class varies: in read binary\n"
+"mode, it returns a BufferedReader; in write binary and append binary\n"
+"modes, it returns a BufferedWriter, and in read/write mode, it returns\n"
+"a BufferedRandom.\n"
+"\n"
+"It is also possible to use a string or bytearray as a file for both\n"
+"reading and writing. For strings StringIO can be used like a file\n"
+"opened in a text mode, and for bytes a BytesIO can be used like a file\n"
+"opened in a binary mode.");
+
+#define _IO_OPEN_METHODDEF \
+ {"open", (PyCFunction)_io_open, METH_VARARGS|METH_KEYWORDS, _io_open__doc__},
+
+static PyObject *
+_io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
+ int buffering, const char *encoding, const char *errors,
+ const char *newline, int closefd, PyObject *opener);
+
+static PyObject *
+_io_open(PyModuleDef *module, PyObject *args, PyObject *kwargs)
+{
+ PyObject *return_value = NULL;
+ static char *_keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
+ PyObject *file;
+ const char *mode = "r";
+ int buffering = -1;
+ const char *encoding = NULL;
+ const char *errors = NULL;
+ const char *newline = NULL;
+ int closefd = 1;
+ PyObject *opener = Py_None;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|sizzziO:open", _keywords,
+ &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=c51a5a443c11f02b input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
new file mode 100644
index 0000000..b79b8d5
--- /dev/null
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -0,0 +1,474 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__,
+"readinto($self, buffer, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFEREDIOBASE_READINTO_METHODDEF \
+ {"readinto", (PyCFunction)_io__BufferedIOBase_readinto, METH_O, _io__BufferedIOBase_readinto__doc__},
+
+static PyObject *
+_io__BufferedIOBase_readinto_impl(PyObject *self, Py_buffer *buffer);
+
+static PyObject *
+_io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto",
+ &buffer))
+ goto exit;
+ return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__BufferedIOBase_readinto1__doc__,
+"readinto1($self, buffer, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFEREDIOBASE_READINTO1_METHODDEF \
+ {"readinto1", (PyCFunction)_io__BufferedIOBase_readinto1, METH_O, _io__BufferedIOBase_readinto1__doc__},
+
+static PyObject *
+_io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer);
+
+static PyObject *
+_io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto1",
+ &buffer))
+ goto exit;
+ return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__BufferedIOBase_detach__doc__,
+"detach($self, /)\n"
+"--\n"
+"\n"
+"Disconnect this buffer from its underlying raw stream and return it.\n"
+"\n"
+"After the raw stream has been detached, the buffer is in an unusable\n"
+"state.");
+
+#define _IO__BUFFEREDIOBASE_DETACH_METHODDEF \
+ {"detach", (PyCFunction)_io__BufferedIOBase_detach, METH_NOARGS, _io__BufferedIOBase_detach__doc__},
+
+static PyObject *
+_io__BufferedIOBase_detach_impl(PyObject *self);
+
+static PyObject *
+_io__BufferedIOBase_detach(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__BufferedIOBase_detach_impl(self);
+}
+
+PyDoc_STRVAR(_io__Buffered_peek__doc__,
+"peek($self, size=0, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_PEEK_METHODDEF \
+ {"peek", (PyCFunction)_io__Buffered_peek, METH_VARARGS, _io__Buffered_peek__doc__},
+
+static PyObject *
+_io__Buffered_peek_impl(buffered *self, Py_ssize_t size);
+
+static PyObject *
+_io__Buffered_peek(buffered *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t size = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "|n:peek",
+ &size))
+ goto exit;
+ return_value = _io__Buffered_peek_impl(self, size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_read__doc__,
+"read($self, size=-1, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_READ_METHODDEF \
+ {"read", (PyCFunction)_io__Buffered_read, METH_VARARGS, _io__Buffered_read__doc__},
+
+static PyObject *
+_io__Buffered_read_impl(buffered *self, Py_ssize_t n);
+
+static PyObject *
+_io__Buffered_read(buffered *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t n = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|O&:read",
+ _PyIO_ConvertSsize_t, &n))
+ goto exit;
+ return_value = _io__Buffered_read_impl(self, n);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_read1__doc__,
+"read1($self, size, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_READ1_METHODDEF \
+ {"read1", (PyCFunction)_io__Buffered_read1, METH_O, _io__Buffered_read1__doc__},
+
+static PyObject *
+_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
+
+static PyObject *
+_io__Buffered_read1(buffered *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t n;
+
+ if (!PyArg_Parse(arg,
+ "n:read1",
+ &n))
+ goto exit;
+ return_value = _io__Buffered_read1_impl(self, n);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_readinto__doc__,
+"readinto($self, buffer, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_READINTO_METHODDEF \
+ {"readinto", (PyCFunction)_io__Buffered_readinto, METH_O, _io__Buffered_readinto__doc__},
+
+static PyObject *
+_io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer);
+
+static PyObject *
+_io__Buffered_readinto(buffered *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto",
+ &buffer))
+ goto exit;
+ return_value = _io__Buffered_readinto_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_readinto1__doc__,
+"readinto1($self, buffer, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_READINTO1_METHODDEF \
+ {"readinto1", (PyCFunction)_io__Buffered_readinto1, METH_O, _io__Buffered_readinto1__doc__},
+
+static PyObject *
+_io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer);
+
+static PyObject *
+_io__Buffered_readinto1(buffered *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto1",
+ &buffer))
+ goto exit;
+ return_value = _io__Buffered_readinto1_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_readline__doc__,
+"readline($self, size=-1, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_READLINE_METHODDEF \
+ {"readline", (PyCFunction)_io__Buffered_readline, METH_VARARGS, _io__Buffered_readline__doc__},
+
+static PyObject *
+_io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
+
+static PyObject *
+_io__Buffered_readline(buffered *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t size = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|O&:readline",
+ _PyIO_ConvertSsize_t, &size))
+ goto exit;
+ return_value = _io__Buffered_readline_impl(self, size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_seek__doc__,
+"seek($self, target, whence=0, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_SEEK_METHODDEF \
+ {"seek", (PyCFunction)_io__Buffered_seek, METH_VARARGS, _io__Buffered_seek__doc__},
+
+static PyObject *
+_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
+
+static PyObject *
+_io__Buffered_seek(buffered *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *targetobj;
+ int whence = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "O|i:seek",
+ &targetobj, &whence))
+ goto exit;
+ return_value = _io__Buffered_seek_impl(self, targetobj, whence);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__Buffered_truncate__doc__,
+"truncate($self, pos=None, /)\n"
+"--\n"
+"\n");
+
+#define _IO__BUFFERED_TRUNCATE_METHODDEF \
+ {"truncate", (PyCFunction)_io__Buffered_truncate, METH_VARARGS, _io__Buffered_truncate__doc__},
+
+static PyObject *
+_io__Buffered_truncate_impl(buffered *self, PyObject *pos);
+
+static PyObject *
+_io__Buffered_truncate(buffered *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *pos = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "truncate",
+ 0, 1,
+ &pos))
+ goto exit;
+ return_value = _io__Buffered_truncate_impl(self, pos);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BufferedReader___init____doc__,
+"BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
+"--\n"
+"\n"
+"Create a new buffered reader using the given readable raw IO object.");
+
+static int
+_io_BufferedReader___init___impl(buffered *self, PyObject *raw,
+ Py_ssize_t buffer_size);
+
+static int
+_io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"raw", "buffer_size", NULL};
+ PyObject *raw;
+ Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|n:BufferedReader", _keywords,
+ &raw, &buffer_size))
+ goto exit;
+ return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BufferedWriter___init____doc__,
+"BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
+"--\n"
+"\n"
+"A buffer for a writeable sequential RawIO object.\n"
+"\n"
+"The constructor creates a BufferedWriter for the given writeable raw\n"
+"stream. If the buffer_size is not given, it defaults to\n"
+"DEFAULT_BUFFER_SIZE.");
+
+static int
+_io_BufferedWriter___init___impl(buffered *self, PyObject *raw,
+ Py_ssize_t buffer_size);
+
+static int
+_io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"raw", "buffer_size", NULL};
+ PyObject *raw;
+ Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|n:BufferedWriter", _keywords,
+ &raw, &buffer_size))
+ goto exit;
+ return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BufferedWriter_write__doc__,
+"write($self, buffer, /)\n"
+"--\n"
+"\n");
+
+#define _IO_BUFFEREDWRITER_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io_BufferedWriter_write, METH_O, _io_BufferedWriter_write__doc__},
+
+static PyObject *
+_io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer);
+
+static PyObject *
+_io_BufferedWriter_write(buffered *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "y*:write",
+ &buffer))
+ goto exit;
+ return_value = _io_BufferedWriter_write_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BufferedRWPair___init____doc__,
+"BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE, /)\n"
+"--\n"
+"\n"
+"A buffered reader and writer object together.\n"
+"\n"
+"A buffered reader object and buffered writer object put together to\n"
+"form a sequential IO object that can read and write. This is typically\n"
+"used with a socket or two-way pipe.\n"
+"\n"
+"reader and writer are RawIOBase objects that are readable and\n"
+"writeable respectively. If the buffer_size is omitted it defaults to\n"
+"DEFAULT_BUFFER_SIZE.");
+
+static int
+_io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader,
+ PyObject *writer, Py_ssize_t buffer_size);
+
+static int
+_io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ PyObject *reader;
+ PyObject *writer;
+ Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
+
+ if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
+ !_PyArg_NoKeywords("BufferedRWPair", kwargs))
+ goto exit;
+ if (!PyArg_ParseTuple(args,
+ "OO|n:BufferedRWPair",
+ &reader, &writer, &buffer_size))
+ goto exit;
+ return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BufferedRandom___init____doc__,
+"BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
+"--\n"
+"\n"
+"A buffered interface to random access streams.\n"
+"\n"
+"The constructor creates a reader and writer for a seekable stream,\n"
+"raw, given in the first argument. If the buffer_size is omitted it\n"
+"defaults to DEFAULT_BUFFER_SIZE.");
+
+static int
+_io_BufferedRandom___init___impl(buffered *self, PyObject *raw,
+ Py_ssize_t buffer_size);
+
+static int
+_io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"raw", "buffer_size", NULL};
+ PyObject *raw;
+ Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|n:BufferedRandom", _keywords,
+ &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=78808e39f36e3fa9 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
new file mode 100644
index 0000000..695c46a
--- /dev/null
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -0,0 +1,426 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io_BytesIO_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be read.");
+
+#define _IO_BYTESIO_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io_BytesIO_readable, METH_NOARGS, _io_BytesIO_readable__doc__},
+
+static PyObject *
+_io_BytesIO_readable_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_readable(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_readable_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be written.");
+
+#define _IO_BYTESIO_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io_BytesIO_writable, METH_NOARGS, _io_BytesIO_writable__doc__},
+
+static PyObject *
+_io_BytesIO_writable_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_writable(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_writable_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_seekable__doc__,
+"seekable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be seeked.");
+
+#define _IO_BYTESIO_SEEKABLE_METHODDEF \
+ {"seekable", (PyCFunction)_io_BytesIO_seekable, METH_NOARGS, _io_BytesIO_seekable__doc__},
+
+static PyObject *
+_io_BytesIO_seekable_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_seekable(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_seekable_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_flush__doc__,
+"flush($self, /)\n"
+"--\n"
+"\n"
+"Does nothing.");
+
+#define _IO_BYTESIO_FLUSH_METHODDEF \
+ {"flush", (PyCFunction)_io_BytesIO_flush, METH_NOARGS, _io_BytesIO_flush__doc__},
+
+static PyObject *
+_io_BytesIO_flush_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_flush(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_flush_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_getbuffer__doc__,
+"getbuffer($self, /)\n"
+"--\n"
+"\n"
+"Get a read-write view over the contents of the BytesIO object.");
+
+#define _IO_BYTESIO_GETBUFFER_METHODDEF \
+ {"getbuffer", (PyCFunction)_io_BytesIO_getbuffer, METH_NOARGS, _io_BytesIO_getbuffer__doc__},
+
+static PyObject *
+_io_BytesIO_getbuffer_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_getbuffer(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_getbuffer_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_getvalue__doc__,
+"getvalue($self, /)\n"
+"--\n"
+"\n"
+"Retrieve the entire contents of the BytesIO object.");
+
+#define _IO_BYTESIO_GETVALUE_METHODDEF \
+ {"getvalue", (PyCFunction)_io_BytesIO_getvalue, METH_NOARGS, _io_BytesIO_getvalue__doc__},
+
+static PyObject *
+_io_BytesIO_getvalue_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_getvalue(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_getvalue_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_isatty__doc__,
+"isatty($self, /)\n"
+"--\n"
+"\n"
+"Always returns False.\n"
+"\n"
+"BytesIO objects are not connected to a TTY-like device.");
+
+#define _IO_BYTESIO_ISATTY_METHODDEF \
+ {"isatty", (PyCFunction)_io_BytesIO_isatty, METH_NOARGS, _io_BytesIO_isatty__doc__},
+
+static PyObject *
+_io_BytesIO_isatty_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_isatty(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_isatty_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_tell__doc__,
+"tell($self, /)\n"
+"--\n"
+"\n"
+"Current file position, an integer.");
+
+#define _IO_BYTESIO_TELL_METHODDEF \
+ {"tell", (PyCFunction)_io_BytesIO_tell, METH_NOARGS, _io_BytesIO_tell__doc__},
+
+static PyObject *
+_io_BytesIO_tell_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_tell(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_tell_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO_read__doc__,
+"read($self, size=None, /)\n"
+"--\n"
+"\n"
+"Read at most size bytes, returned as a bytes object.\n"
+"\n"
+"If the size argument is negative, read until EOF is reached.\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO_BYTESIO_READ_METHODDEF \
+ {"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__},
+
+static PyObject *
+_io_BytesIO_read_impl(bytesio *self, PyObject *arg);
+
+static PyObject *
+_io_BytesIO_read(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "read",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_BytesIO_read_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_read1__doc__,
+"read1($self, size, /)\n"
+"--\n"
+"\n"
+"Read at most size bytes, returned as a bytes object.\n"
+"\n"
+"If the size argument is negative or omitted, read until EOF is reached.\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO_BYTESIO_READ1_METHODDEF \
+ {"read1", (PyCFunction)_io_BytesIO_read1, METH_O, _io_BytesIO_read1__doc__},
+
+PyDoc_STRVAR(_io_BytesIO_readline__doc__,
+"readline($self, size=None, /)\n"
+"--\n"
+"\n"
+"Next line from the file, as a bytes object.\n"
+"\n"
+"Retain newline. A non-negative size argument limits the maximum\n"
+"number of bytes to return (an incomplete line may be returned then).\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO_BYTESIO_READLINE_METHODDEF \
+ {"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__},
+
+static PyObject *
+_io_BytesIO_readline_impl(bytesio *self, PyObject *arg);
+
+static PyObject *
+_io_BytesIO_readline(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "readline",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_BytesIO_readline_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_readlines__doc__,
+"readlines($self, size=None, /)\n"
+"--\n"
+"\n"
+"List of bytes objects, each a line from the file.\n"
+"\n"
+"Call readline() repeatedly and return a list of the lines so read.\n"
+"The optional size argument, if given, is an approximate bound on the\n"
+"total number of bytes in the lines returned.");
+
+#define _IO_BYTESIO_READLINES_METHODDEF \
+ {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__},
+
+static PyObject *
+_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
+
+static PyObject *
+_io_BytesIO_readlines(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "readlines",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_BytesIO_readlines_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_readinto__doc__,
+"readinto($self, buffer, /)\n"
+"--\n"
+"\n"
+"Read up to len(buffer) bytes into buffer.\n"
+"\n"
+"Returns number of bytes read (0 for EOF), or None if the object\n"
+"is set not to block as has no data to read.");
+
+#define _IO_BYTESIO_READINTO_METHODDEF \
+ {"readinto", (PyCFunction)_io_BytesIO_readinto, METH_O, _io_BytesIO_readinto__doc__},
+
+static PyObject *
+_io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer);
+
+static PyObject *
+_io_BytesIO_readinto(bytesio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto",
+ &buffer))
+ goto exit;
+ return_value = _io_BytesIO_readinto_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_truncate__doc__,
+"truncate($self, size=None, /)\n"
+"--\n"
+"\n"
+"Truncate the file to at most size bytes.\n"
+"\n"
+"Size defaults to the current file position, as returned by tell().\n"
+"The current file position is unchanged. Returns the new size.");
+
+#define _IO_BYTESIO_TRUNCATE_METHODDEF \
+ {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__},
+
+static PyObject *
+_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg);
+
+static PyObject *
+_io_BytesIO_truncate(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "truncate",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_BytesIO_truncate_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_seek__doc__,
+"seek($self, pos, whence=0, /)\n"
+"--\n"
+"\n"
+"Change stream position.\n"
+"\n"
+"Seek to byte offset pos relative to position indicated by whence:\n"
+" 0 Start of stream (the default). pos should be >= 0;\n"
+" 1 Current position - pos may be negative;\n"
+" 2 End of stream - pos usually negative.\n"
+"Returns the new absolute position.");
+
+#define _IO_BYTESIO_SEEK_METHODDEF \
+ {"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__},
+
+static PyObject *
+_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);
+
+static PyObject *
+_io_BytesIO_seek(bytesio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t pos;
+ int whence = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "n|i:seek",
+ &pos, &whence))
+ goto exit;
+ return_value = _io_BytesIO_seek_impl(self, pos, whence);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_BytesIO_write__doc__,
+"write($self, b, /)\n"
+"--\n"
+"\n"
+"Write bytes to file.\n"
+"\n"
+"Return the number of bytes written.");
+
+#define _IO_BYTESIO_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io_BytesIO_write, METH_O, _io_BytesIO_write__doc__},
+
+PyDoc_STRVAR(_io_BytesIO_writelines__doc__,
+"writelines($self, lines, /)\n"
+"--\n"
+"\n"
+"Write lines to the file.\n"
+"\n"
+"Note that newlines are not added. lines can be any iterable object\n"
+"producing bytes-like objects. This is equivalent to calling write() for\n"
+"each element.");
+
+#define _IO_BYTESIO_WRITELINES_METHODDEF \
+ {"writelines", (PyCFunction)_io_BytesIO_writelines, METH_O, _io_BytesIO_writelines__doc__},
+
+PyDoc_STRVAR(_io_BytesIO_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Disable all I/O operations.");
+
+#define _IO_BYTESIO_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io_BytesIO_close, METH_NOARGS, _io_BytesIO_close__doc__},
+
+static PyObject *
+_io_BytesIO_close_impl(bytesio *self);
+
+static PyObject *
+_io_BytesIO_close(bytesio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_BytesIO_close_impl(self);
+}
+
+PyDoc_STRVAR(_io_BytesIO___init____doc__,
+"BytesIO(initial_bytes=b\'\')\n"
+"--\n"
+"\n"
+"Buffered I/O implementation using an in-memory bytes buffer.");
+
+static int
+_io_BytesIO___init___impl(bytesio *self, PyObject *initvalue);
+
+static int
+_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"initial_bytes", NULL};
+ PyObject *initvalue = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|O:BytesIO", _keywords,
+ &initvalue))
+ goto exit;
+ return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=e22697ada514f4eb input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
new file mode 100644
index 0000000..bb68cc9
--- /dev/null
+++ b/Modules/_io/clinic/fileio.c.h
@@ -0,0 +1,374 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io_FileIO_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Close the file.\n"
+"\n"
+"A closed file cannot be used for further I/O operations. close() may be\n"
+"called more than once without error.");
+
+#define _IO_FILEIO_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io_FileIO_close, METH_NOARGS, _io_FileIO_close__doc__},
+
+static PyObject *
+_io_FileIO_close_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_close(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_close_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO___init____doc__,
+"FileIO(file, mode=\'r\', closefd=True, opener=None)\n"
+"--\n"
+"\n"
+"Open a file.\n"
+"\n"
+"The mode can be \'r\' (default), \'w\', \'x\' or \'a\' for reading,\n"
+"writing, exclusive creation or appending. The file will be created if it\n"
+"doesn\'t exist when opened for writing or appending; it will be truncated\n"
+"when opened for writing. A FileExistsError will be raised if it already\n"
+"exists when opened for creating. Opening a file for creating implies\n"
+"writing so this mode behaves in a similar way to \'w\'.Add a \'+\' to the mode\n"
+"to allow simultaneous reading and writing. A custom opener can be used by\n"
+"passing a callable as *opener*. The underlying file descriptor for the file\n"
+"object is then obtained by calling opener with (*name*, *flags*).\n"
+"*opener* must return an open file descriptor (passing os.open as *opener*\n"
+"results in functionality similar to passing None).");
+
+static int
+_io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
+ int closefd, PyObject *opener);
+
+static int
+_io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ 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))
+ goto exit;
+ return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_FileIO_fileno__doc__,
+"fileno($self, /)\n"
+"--\n"
+"\n"
+"Return the underlying file descriptor (an integer).");
+
+#define _IO_FILEIO_FILENO_METHODDEF \
+ {"fileno", (PyCFunction)_io_FileIO_fileno, METH_NOARGS, _io_FileIO_fileno__doc__},
+
+static PyObject *
+_io_FileIO_fileno_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_fileno(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_fileno_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n"
+"True if file was opened in a read mode.");
+
+#define _IO_FILEIO_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io_FileIO_readable, METH_NOARGS, _io_FileIO_readable__doc__},
+
+static PyObject *
+_io_FileIO_readable_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_readable(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_readable_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n"
+"True if file was opened in a write mode.");
+
+#define _IO_FILEIO_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io_FileIO_writable, METH_NOARGS, _io_FileIO_writable__doc__},
+
+static PyObject *
+_io_FileIO_writable_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_writable(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_writable_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO_seekable__doc__,
+"seekable($self, /)\n"
+"--\n"
+"\n"
+"True if file supports random-access.");
+
+#define _IO_FILEIO_SEEKABLE_METHODDEF \
+ {"seekable", (PyCFunction)_io_FileIO_seekable, METH_NOARGS, _io_FileIO_seekable__doc__},
+
+static PyObject *
+_io_FileIO_seekable_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_seekable(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_seekable_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO_readinto__doc__,
+"readinto($self, buffer, /)\n"
+"--\n"
+"\n"
+"Same as RawIOBase.readinto().");
+
+#define _IO_FILEIO_READINTO_METHODDEF \
+ {"readinto", (PyCFunction)_io_FileIO_readinto, METH_O, _io_FileIO_readinto__doc__},
+
+static PyObject *
+_io_FileIO_readinto_impl(fileio *self, Py_buffer *buffer);
+
+static PyObject *
+_io_FileIO_readinto(fileio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer buffer = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "w*:readinto",
+ &buffer))
+ goto exit;
+ return_value = _io_FileIO_readinto_impl(self, &buffer);
+
+exit:
+ /* Cleanup for buffer */
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_FileIO_readall__doc__,
+"readall($self, /)\n"
+"--\n"
+"\n"
+"Read all data from the file, returned as bytes.\n"
+"\n"
+"In non-blocking mode, returns as much as is immediately available,\n"
+"or None if no data is available. Return an empty bytes object at EOF.");
+
+#define _IO_FILEIO_READALL_METHODDEF \
+ {"readall", (PyCFunction)_io_FileIO_readall, METH_NOARGS, _io_FileIO_readall__doc__},
+
+static PyObject *
+_io_FileIO_readall_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_readall(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_readall_impl(self);
+}
+
+PyDoc_STRVAR(_io_FileIO_read__doc__,
+"read($self, size=-1, /)\n"
+"--\n"
+"\n"
+"Read at most size bytes, returned as bytes.\n"
+"\n"
+"Only makes one system call, so less data may be returned than requested.\n"
+"In non-blocking mode, returns None if no data is available.\n"
+"Return an empty bytes object at EOF.");
+
+#define _IO_FILEIO_READ_METHODDEF \
+ {"read", (PyCFunction)_io_FileIO_read, METH_VARARGS, _io_FileIO_read__doc__},
+
+static PyObject *
+_io_FileIO_read_impl(fileio *self, Py_ssize_t size);
+
+static PyObject *
+_io_FileIO_read(fileio *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_FileIO_read_impl(self, size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_FileIO_write__doc__,
+"write($self, b, /)\n"
+"--\n"
+"\n"
+"Write bytes b to file, return number 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. In non-blocking mode,\n"
+"returns None if the write would block.");
+
+#define _IO_FILEIO_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io_FileIO_write, METH_O, _io_FileIO_write__doc__},
+
+static PyObject *
+_io_FileIO_write_impl(fileio *self, Py_buffer *b);
+
+static PyObject *
+_io_FileIO_write(fileio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer b = {NULL, NULL};
+
+ if (!PyArg_Parse(arg,
+ "y*:write",
+ &b))
+ goto exit;
+ return_value = _io_FileIO_write_impl(self, &b);
+
+exit:
+ /* Cleanup for b */
+ if (b.obj)
+ PyBuffer_Release(&b);
+
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_FileIO_seek__doc__,
+"seek($self, pos, whence=0, /)\n"
+"--\n"
+"\n"
+"Move to new file position and return the file position.\n"
+"\n"
+"Argument offset is a byte count. Optional argument whence defaults to\n"
+"SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values\n"
+"are SEEK_CUR or 1 (move relative to current position, positive or negative),\n"
+"and SEEK_END or 2 (move relative to end of file, usually negative, although\n"
+"many platforms allow seeking beyond the end of a file).\n"
+"\n"
+"Note that not all file objects are seekable.");
+
+#define _IO_FILEIO_SEEK_METHODDEF \
+ {"seek", (PyCFunction)_io_FileIO_seek, METH_VARARGS, _io_FileIO_seek__doc__},
+
+static PyObject *
+_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);
+
+static PyObject *
+_io_FileIO_seek(fileio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *pos;
+ int whence = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "O|i:seek",
+ &pos, &whence))
+ goto exit;
+ return_value = _io_FileIO_seek_impl(self, pos, whence);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_FileIO_tell__doc__,
+"tell($self, /)\n"
+"--\n"
+"\n"
+"Current file position.\n"
+"\n"
+"Can raise OSError for non seekable files.");
+
+#define _IO_FILEIO_TELL_METHODDEF \
+ {"tell", (PyCFunction)_io_FileIO_tell, METH_NOARGS, _io_FileIO_tell__doc__},
+
+static PyObject *
+_io_FileIO_tell_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_tell(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_tell_impl(self);
+}
+
+#if defined(HAVE_FTRUNCATE)
+
+PyDoc_STRVAR(_io_FileIO_truncate__doc__,
+"truncate($self, size=None, /)\n"
+"--\n"
+"\n"
+"Truncate the file to at most size bytes and return the truncated size.\n"
+"\n"
+"Size defaults to the current file position, as returned by tell().\n"
+"The current file position is changed to the value of size.");
+
+#define _IO_FILEIO_TRUNCATE_METHODDEF \
+ {"truncate", (PyCFunction)_io_FileIO_truncate, METH_VARARGS, _io_FileIO_truncate__doc__},
+
+static PyObject *
+_io_FileIO_truncate_impl(fileio *self, PyObject *posobj);
+
+static PyObject *
+_io_FileIO_truncate(fileio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *posobj = NULL;
+
+ if (!PyArg_UnpackTuple(args, "truncate",
+ 0, 1,
+ &posobj))
+ goto exit;
+ return_value = _io_FileIO_truncate_impl(self, posobj);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(HAVE_FTRUNCATE) */
+
+PyDoc_STRVAR(_io_FileIO_isatty__doc__,
+"isatty($self, /)\n"
+"--\n"
+"\n"
+"True if the file is connected to a TTY device.");
+
+#define _IO_FILEIO_ISATTY_METHODDEF \
+ {"isatty", (PyCFunction)_io_FileIO_isatty, METH_NOARGS, _io_FileIO_isatty__doc__},
+
+static PyObject *
+_io_FileIO_isatty_impl(fileio *self);
+
+static PyObject *
+_io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_FileIO_isatty_impl(self);
+}
+
+#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
+ #define _IO_FILEIO_TRUNCATE_METHODDEF
+#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
+/*[clinic end generated code: output=c6708e1980f6e02d input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h
new file mode 100644
index 0000000..ce47faa
--- /dev/null
+++ b/Modules/_io/clinic/iobase.c.h
@@ -0,0 +1,282 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io__IOBase_tell__doc__,
+"tell($self, /)\n"
+"--\n"
+"\n"
+"Return current stream position.");
+
+#define _IO__IOBASE_TELL_METHODDEF \
+ {"tell", (PyCFunction)_io__IOBase_tell, METH_NOARGS, _io__IOBase_tell__doc__},
+
+static PyObject *
+_io__IOBase_tell_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_tell(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_tell_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_flush__doc__,
+"flush($self, /)\n"
+"--\n"
+"\n"
+"Flush write buffers, if applicable.\n"
+"\n"
+"This is not implemented for read-only and non-blocking streams.");
+
+#define _IO__IOBASE_FLUSH_METHODDEF \
+ {"flush", (PyCFunction)_io__IOBase_flush, METH_NOARGS, _io__IOBase_flush__doc__},
+
+static PyObject *
+_io__IOBase_flush_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_flush_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Flush and close the IO object.\n"
+"\n"
+"This method has no effect if the file is already closed.");
+
+#define _IO__IOBASE_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io__IOBase_close, METH_NOARGS, _io__IOBase_close__doc__},
+
+static PyObject *
+_io__IOBase_close_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_close(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_close_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_seekable__doc__,
+"seekable($self, /)\n"
+"--\n"
+"\n"
+"Return whether object supports random access.\n"
+"\n"
+"If False, seek(), tell() and truncate() will raise UnsupportedOperation.\n"
+"This method may need to do a test seek().");
+
+#define _IO__IOBASE_SEEKABLE_METHODDEF \
+ {"seekable", (PyCFunction)_io__IOBase_seekable, METH_NOARGS, _io__IOBase_seekable__doc__},
+
+static PyObject *
+_io__IOBase_seekable_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_seekable(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_seekable_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n"
+"Return whether object was opened for reading.\n"
+"\n"
+"If False, read() will raise UnsupportedOperation.");
+
+#define _IO__IOBASE_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io__IOBase_readable, METH_NOARGS, _io__IOBase_readable__doc__},
+
+static PyObject *
+_io__IOBase_readable_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_readable(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_readable_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n"
+"Return whether object was opened for writing.\n"
+"\n"
+"If False, write() will raise UnsupportedOperation.");
+
+#define _IO__IOBASE_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io__IOBase_writable, METH_NOARGS, _io__IOBase_writable__doc__},
+
+static PyObject *
+_io__IOBase_writable_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_writable_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_fileno__doc__,
+"fileno($self, /)\n"
+"--\n"
+"\n"
+"Returns underlying file descriptor if one exists.\n"
+"\n"
+"An IOError is raised if the IO object does not use a file descriptor.");
+
+#define _IO__IOBASE_FILENO_METHODDEF \
+ {"fileno", (PyCFunction)_io__IOBase_fileno, METH_NOARGS, _io__IOBase_fileno__doc__},
+
+static PyObject *
+_io__IOBase_fileno_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_fileno(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_fileno_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_isatty__doc__,
+"isatty($self, /)\n"
+"--\n"
+"\n"
+"Return whether this is an \'interactive\' stream.\n"
+"\n"
+"Return False if it can\'t be determined.");
+
+#define _IO__IOBASE_ISATTY_METHODDEF \
+ {"isatty", (PyCFunction)_io__IOBase_isatty, METH_NOARGS, _io__IOBase_isatty__doc__},
+
+static PyObject *
+_io__IOBase_isatty_impl(PyObject *self);
+
+static PyObject *
+_io__IOBase_isatty(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__IOBase_isatty_impl(self);
+}
+
+PyDoc_STRVAR(_io__IOBase_readline__doc__,
+"readline($self, size=-1, /)\n"
+"--\n"
+"\n"
+"Read and return a line from the stream.\n"
+"\n"
+"If size is specified, at most size bytes will be read.\n"
+"\n"
+"The line terminator is always b\'\\n\' for binary files; for text\n"
+"files, the newlines argument to open can be used to select the line\n"
+"terminator(s) recognized.");
+
+#define _IO__IOBASE_READLINE_METHODDEF \
+ {"readline", (PyCFunction)_io__IOBase_readline, METH_VARARGS, _io__IOBase_readline__doc__},
+
+static PyObject *
+_io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit);
+
+static PyObject *
+_io__IOBase_readline(PyObject *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t limit = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|O&:readline",
+ _PyIO_ConvertSsize_t, &limit))
+ goto exit;
+ return_value = _io__IOBase_readline_impl(self, limit);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__IOBase_readlines__doc__,
+"readlines($self, hint=-1, /)\n"
+"--\n"
+"\n"
+"Return a list of lines from the stream.\n"
+"\n"
+"hint can be specified to control the number of lines read: no more\n"
+"lines will be read if the total size (in bytes/characters) of all\n"
+"lines so far exceeds hint.");
+
+#define _IO__IOBASE_READLINES_METHODDEF \
+ {"readlines", (PyCFunction)_io__IOBase_readlines, METH_VARARGS, _io__IOBase_readlines__doc__},
+
+static PyObject *
+_io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint);
+
+static PyObject *
+_io__IOBase_readlines(PyObject *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t hint = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|O&:readlines",
+ _PyIO_ConvertSsize_t, &hint))
+ goto exit;
+ return_value = _io__IOBase_readlines_impl(self, hint);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__IOBase_writelines__doc__,
+"writelines($self, lines, /)\n"
+"--\n"
+"\n");
+
+#define _IO__IOBASE_WRITELINES_METHODDEF \
+ {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},
+
+PyDoc_STRVAR(_io__RawIOBase_read__doc__,
+"read($self, size=-1, /)\n"
+"--\n"
+"\n");
+
+#define _IO__RAWIOBASE_READ_METHODDEF \
+ {"read", (PyCFunction)_io__RawIOBase_read, METH_VARARGS, _io__RawIOBase_read__doc__},
+
+static PyObject *
+_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n);
+
+static PyObject *
+_io__RawIOBase_read(PyObject *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t n = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|n:read",
+ &n))
+ goto exit;
+ return_value = _io__RawIOBase_read_impl(self, n);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io__RawIOBase_readall__doc__,
+"readall($self, /)\n"
+"--\n"
+"\n"
+"Read until EOF, using multiple read() call.");
+
+#define _IO__RAWIOBASE_READALL_METHODDEF \
+ {"readall", (PyCFunction)_io__RawIOBase_readall, METH_NOARGS, _io__RawIOBase_readall__doc__},
+
+static PyObject *
+_io__RawIOBase_readall_impl(PyObject *self);
+
+static PyObject *
+_io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io__RawIOBase_readall_impl(self);
+}
+/*[clinic end generated code: output=84eef4b7541f54b7 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
new file mode 100644
index 0000000..b830c6d
--- /dev/null
+++ b/Modules/_io/clinic/stringio.c.h
@@ -0,0 +1,288 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
+"getvalue($self, /)\n"
+"--\n"
+"\n"
+"Retrieve the entire contents of the object.");
+
+#define _IO_STRINGIO_GETVALUE_METHODDEF \
+ {"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
+
+static PyObject *
+_io_StringIO_getvalue_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_getvalue_impl(self);
+}
+
+PyDoc_STRVAR(_io_StringIO_tell__doc__,
+"tell($self, /)\n"
+"--\n"
+"\n"
+"Tell the current file position.");
+
+#define _IO_STRINGIO_TELL_METHODDEF \
+ {"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
+
+static PyObject *
+_io_StringIO_tell_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_tell_impl(self);
+}
+
+PyDoc_STRVAR(_io_StringIO_read__doc__,
+"read($self, size=None, /)\n"
+"--\n"
+"\n"
+"Read at most size characters, returned as a string.\n"
+"\n"
+"If the argument is negative or omitted, read until EOF\n"
+"is reached. Return an empty string at EOF.");
+
+#define _IO_STRINGIO_READ_METHODDEF \
+ {"read", (PyCFunction)_io_StringIO_read, METH_VARARGS, _io_StringIO_read__doc__},
+
+static PyObject *
+_io_StringIO_read_impl(stringio *self, PyObject *arg);
+
+static PyObject *
+_io_StringIO_read(stringio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "read",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_StringIO_read_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_StringIO_readline__doc__,
+"readline($self, size=None, /)\n"
+"--\n"
+"\n"
+"Read until newline or EOF.\n"
+"\n"
+"Returns an empty string if EOF is hit immediately.");
+
+#define _IO_STRINGIO_READLINE_METHODDEF \
+ {"readline", (PyCFunction)_io_StringIO_readline, METH_VARARGS, _io_StringIO_readline__doc__},
+
+static PyObject *
+_io_StringIO_readline_impl(stringio *self, PyObject *arg);
+
+static PyObject *
+_io_StringIO_readline(stringio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "readline",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_StringIO_readline_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_StringIO_truncate__doc__,
+"truncate($self, pos=None, /)\n"
+"--\n"
+"\n"
+"Truncate size to pos.\n"
+"\n"
+"The pos argument defaults to the current file position, as\n"
+"returned by tell(). The current file position is unchanged.\n"
+"Returns the new absolute position.");
+
+#define _IO_STRINGIO_TRUNCATE_METHODDEF \
+ {"truncate", (PyCFunction)_io_StringIO_truncate, METH_VARARGS, _io_StringIO_truncate__doc__},
+
+static PyObject *
+_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
+
+static PyObject *
+_io_StringIO_truncate(stringio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *arg = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "truncate",
+ 0, 1,
+ &arg))
+ goto exit;
+ return_value = _io_StringIO_truncate_impl(self, arg);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_StringIO_seek__doc__,
+"seek($self, pos, whence=0, /)\n"
+"--\n"
+"\n"
+"Change stream position.\n"
+"\n"
+"Seek to character offset pos relative to position indicated by whence:\n"
+" 0 Start of stream (the default). pos should be >= 0;\n"
+" 1 Current position - pos must be 0;\n"
+" 2 End of stream - pos must be 0.\n"
+"Returns the new absolute position.");
+
+#define _IO_STRINGIO_SEEK_METHODDEF \
+ {"seek", (PyCFunction)_io_StringIO_seek, METH_VARARGS, _io_StringIO_seek__doc__},
+
+static PyObject *
+_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
+
+static PyObject *
+_io_StringIO_seek(stringio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t pos;
+ int whence = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "n|i:seek",
+ &pos, &whence))
+ goto exit;
+ return_value = _io_StringIO_seek_impl(self, pos, whence);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_StringIO_write__doc__,
+"write($self, s, /)\n"
+"--\n"
+"\n"
+"Write string to file.\n"
+"\n"
+"Returns the number of characters written, which is always equal to\n"
+"the length of the string.");
+
+#define _IO_STRINGIO_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
+
+PyDoc_STRVAR(_io_StringIO_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Close the IO object.\n"
+"\n"
+"Attempting any further operation after the object is closed\n"
+"will raise a ValueError.\n"
+"\n"
+"This method has no effect if the file is already closed.");
+
+#define _IO_STRINGIO_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
+
+static PyObject *
+_io_StringIO_close_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_close_impl(self);
+}
+
+PyDoc_STRVAR(_io_StringIO___init____doc__,
+"StringIO(initial_value=\'\', newline=\'\\n\')\n"
+"--\n"
+"\n"
+"Text I/O implementation using an in-memory buffer.\n"
+"\n"
+"The initial_value argument sets the value of object. The newline\n"
+"argument is like the one of TextIOWrapper\'s constructor.");
+
+static int
+_io_StringIO___init___impl(stringio *self, PyObject *value,
+ PyObject *newline_obj);
+
+static int
+_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"initial_value", "newline", NULL};
+ PyObject *value = NULL;
+ PyObject *newline_obj = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:StringIO", _keywords,
+ &value, &newline_obj))
+ goto exit;
+ return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_StringIO_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be read.");
+
+#define _IO_STRINGIO_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
+
+static PyObject *
+_io_StringIO_readable_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_readable_impl(self);
+}
+
+PyDoc_STRVAR(_io_StringIO_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be written.");
+
+#define _IO_STRINGIO_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
+
+static PyObject *
+_io_StringIO_writable_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_writable_impl(self);
+}
+
+PyDoc_STRVAR(_io_StringIO_seekable__doc__,
+"seekable($self, /)\n"
+"--\n"
+"\n"
+"Returns True if the IO object can be seeked.");
+
+#define _IO_STRINGIO_SEEKABLE_METHODDEF \
+ {"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
+
+static PyObject *
+_io_StringIO_seekable_impl(stringio *self);
+
+static PyObject *
+_io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_StringIO_seekable_impl(self);
+}
+/*[clinic end generated code: output=f3062096d357c652 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
new file mode 100644
index 0000000..62603bd
--- /dev/null
+++ b/Modules/_io/clinic/textio.c.h
@@ -0,0 +1,464 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__,
+"IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n"
+"--\n"
+"\n"
+"Codec used when reading a file in universal newlines mode.\n"
+"\n"
+"It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n"
+"It also records the types of newlines encountered. When used with\n"
+"translate=False, it ensures that the newline sequence is returned in\n"
+"one piece. When used with decoder=None, it expects unicode strings as\n"
+"decode input and translates newlines without first invoking an external\n"
+"decoder.");
+
+static int
+_io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
+ PyObject *decoder, int translate,
+ PyObject *errors);
+
+static int
+_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int return_value = -1;
+ static char *_keywords[] = {"decoder", "translate", "errors", NULL};
+ PyObject *decoder;
+ int translate;
+ PyObject *errors = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Oi|O:IncrementalNewlineDecoder", _keywords,
+ &decoder, &translate, &errors))
+ goto exit;
+ return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
+"decode($self, /, input, final=False)\n"
+"--\n"
+"\n");
+
+#define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \
+ {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_VARARGS|METH_KEYWORDS, _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)
+{
+ PyObject *return_value = NULL;
+ static char *_keywords[] = {"input", "final", NULL};
+ PyObject *input;
+ int final = 0;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|i:decode", _keywords,
+ &input, &final))
+ goto exit;
+ return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__,
+"getstate($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \
+ {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__},
+
+static PyObject *
+_io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self);
+
+static PyObject *
+_io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_IncrementalNewlineDecoder_getstate_impl(self);
+}
+
+PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__,
+"setstate($self, state, /)\n"
+"--\n"
+"\n");
+
+#define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \
+ {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__},
+
+PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__,
+"reset($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \
+ {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__},
+
+static PyObject *
+_io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self);
+
+static PyObject *
+_io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_IncrementalNewlineDecoder_reset_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper___init____doc__,
+"TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n"
+" line_buffering=False, write_through=False)\n"
+"--\n"
+"\n"
+"Character and line based layer over a BufferedIOBase object, buffer.\n"
+"\n"
+"encoding gives the name of the encoding that the stream will be\n"
+"decoded or encoded with. It defaults to locale.getpreferredencoding(False).\n"
+"\n"
+"errors determines the strictness of encoding and decoding (see\n"
+"help(codecs.Codec) or the documentation for codecs.register) and\n"
+"defaults to \"strict\".\n"
+"\n"
+"newline controls how line endings are handled. It can be None, \'\',\n"
+"\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n"
+"\n"
+"* On input, if newline is None, universal newlines mode is\n"
+" enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
+" these are translated into \'\\n\' before being returned to the\n"
+" caller. If it is \'\', universal newline mode is enabled, but line\n"
+" endings are returned to the caller untranslated. If it has any of\n"
+" the other legal values, input lines are only terminated by the given\n"
+" string, and the line ending is returned to the caller untranslated.\n"
+"\n"
+"* On output, if newline is None, any \'\\n\' characters written are\n"
+" translated to the system default line separator, os.linesep. If\n"
+" newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
+" of the other legal values, any \'\\n\' characters written are translated\n"
+" to the given string.\n"
+"\n"
+"If line_buffering is True, a call to flush is implied when a call to\n"
+"write contains a newline character.");
+
+static int
+_io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
+ const char *encoding, const char *errors,
+ const char *newline, int line_buffering,
+ int write_through);
+
+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};
+ PyObject *buffer;
+ const char *encoding = NULL;
+ const char *errors = NULL;
+ const char *newline = NULL;
+ 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))
+ goto exit;
+ return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__,
+"detach($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \
+ {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__},
+
+static PyObject *
+_io_TextIOWrapper_detach_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_detach_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_write__doc__,
+"write($self, text, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \
+ {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__},
+
+static PyObject *
+_io_TextIOWrapper_write_impl(textio *self, PyObject *text);
+
+static PyObject *
+_io_TextIOWrapper_write(textio *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ PyObject *text;
+
+ if (!PyArg_Parse(arg,
+ "U:write",
+ &text))
+ goto exit;
+ return_value = _io_TextIOWrapper_write_impl(self, text);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_read__doc__,
+"read($self, size=-1, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_READ_METHODDEF \
+ {"read", (PyCFunction)_io_TextIOWrapper_read, METH_VARARGS, _io_TextIOWrapper_read__doc__},
+
+static PyObject *
+_io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
+
+static PyObject *
+_io_TextIOWrapper_read(textio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t n = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|O&:read",
+ _PyIO_ConvertSsize_t, &n))
+ goto exit;
+ return_value = _io_TextIOWrapper_read_impl(self, n);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
+"readline($self, size=-1, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \
+ {"readline", (PyCFunction)_io_TextIOWrapper_readline, METH_VARARGS, _io_TextIOWrapper_readline__doc__},
+
+static PyObject *
+_io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
+
+static PyObject *
+_io_TextIOWrapper_readline(textio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ Py_ssize_t size = -1;
+
+ if (!PyArg_ParseTuple(args,
+ "|n:readline",
+ &size))
+ goto exit;
+ return_value = _io_TextIOWrapper_readline_impl(self, size);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
+"seek($self, cookie, whence=0, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \
+ {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_VARARGS, _io_TextIOWrapper_seek__doc__},
+
+static PyObject *
+_io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
+
+static PyObject *
+_io_TextIOWrapper_seek(textio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *cookieObj;
+ int whence = 0;
+
+ if (!PyArg_ParseTuple(args,
+ "O|i:seek",
+ &cookieObj, &whence))
+ goto exit;
+ return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
+"tell($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_TELL_METHODDEF \
+ {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
+
+static PyObject *
+_io_TextIOWrapper_tell_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_tell_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
+"truncate($self, pos=None, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \
+ {"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_VARARGS, _io_TextIOWrapper_truncate__doc__},
+
+static PyObject *
+_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
+
+static PyObject *
+_io_TextIOWrapper_truncate(textio *self, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *pos = Py_None;
+
+ if (!PyArg_UnpackTuple(args, "truncate",
+ 0, 1,
+ &pos))
+ goto exit;
+ return_value = _io_TextIOWrapper_truncate_impl(self, pos);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__,
+"fileno($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \
+ {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__},
+
+static PyObject *
+_io_TextIOWrapper_fileno_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_fileno_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__,
+"seekable($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \
+ {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__},
+
+static PyObject *
+_io_TextIOWrapper_seekable_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_seekable_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__,
+"readable($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \
+ {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__},
+
+static PyObject *
+_io_TextIOWrapper_readable_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_readable_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__,
+"writable($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \
+ {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__},
+
+static PyObject *
+_io_TextIOWrapper_writable_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_writable_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__,
+"isatty($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \
+ {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__},
+
+static PyObject *
+_io_TextIOWrapper_isatty_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_isatty_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__,
+"flush($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \
+ {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__},
+
+static PyObject *
+_io_TextIOWrapper_flush_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_flush_impl(self);
+}
+
+PyDoc_STRVAR(_io_TextIOWrapper_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n");
+
+#define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \
+ {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__},
+
+static PyObject *
+_io_TextIOWrapper_close_impl(textio *self);
+
+static PyObject *
+_io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
+{
+ return _io_TextIOWrapper_close_impl(self);
+}
+/*[clinic end generated code: output=a610bd3b694886c3 input=a9049054013a1b77]*/