Commit 3abac277 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #20175: Converted the _io module to Argument Clinic.

parent 3fa5f6f5
......@@ -190,9 +190,9 @@ class AutoFileTests:
self.assertTrue(f.closed)
def testMethods(self):
methods = ['fileno', 'isatty', 'read',
'tell', 'truncate', 'seekable',
'readable', 'writable']
methods = ['fileno', 'isatty', 'seekable', 'readable', 'writable',
'read', 'readall', 'readline', 'readlines',
'tell', 'truncate', 'flush']
self.f.close()
self.assertTrue(self.f.closed)
......@@ -201,9 +201,15 @@ class AutoFileTests:
method = getattr(self.f, methodname)
# should raise on closed file
self.assertRaises(ValueError, method)
self.assertRaises(ValueError, self.f.readinto, bytearray())
self.assertRaises(ValueError, self.f.seek, 0, os.SEEK_CUR)
self.assertRaises(TypeError, self.f.readinto)
self.assertRaises(ValueError, self.f.readinto, bytearray(1))
self.assertRaises(TypeError, self.f.seek)
self.assertRaises(ValueError, self.f.seek, 0)
self.assertRaises(TypeError, self.f.write)
self.assertRaises(ValueError, self.f.write, b'')
self.assertRaises(TypeError, self.f.writelines)
self.assertRaises(ValueError, self.f.writelines, b'')
def testOpendir(self):
# Issue 3703: opening a directory should fill the errno
......
......@@ -2163,6 +2163,17 @@ class TextIOWrapperTest(unittest.TestCase):
self.assertRaises(TypeError, t.__init__, b, newline=42)
self.assertRaises(ValueError, t.__init__, b, newline='xyzzy')
def test_uninitialized(self):
t = self.TextIOWrapper.__new__(self.TextIOWrapper)
del t
t = self.TextIOWrapper.__new__(self.TextIOWrapper)
self.assertRaises(Exception, repr, t)
self.assertRaisesRegex((ValueError, AttributeError),
'uninitialized|has no attribute',
t.read, 0)
t.__init__(self.MockRawIO())
self.assertEqual(t.read(0), '')
def test_non_text_encoding_codecs_are_rejected(self):
# Ensure the constructor complains if passed a codec that isn't
# marked as a text encoding
......@@ -3024,8 +3035,6 @@ class CTextIOWrapperTest(TextIOWrapperTest):
r = self.BytesIO(b"\xc3\xa9\n\n")
b = self.BufferedReader(r, 1000)
t = self.TextIOWrapper(b)
self.assertRaises(TypeError, t.__init__, b, newline=42)
self.assertRaises(ValueError, t.read)
self.assertRaises(ValueError, t.__init__, b, newline='xyzzy')
self.assertRaises(ValueError, t.read)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*[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]*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*[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]*/
/*[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]*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment