Save new folder
This commit is contained in:
@ -0,0 +1,326 @@
|
||||
/*[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 OSError 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)(void(*)(void))_io_open, METH_FASTCALL|METH_KEYWORDS, _io_open__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_open_impl(PyObject *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(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "open", 0};
|
||||
PyObject *argsbuf[8];
|
||||
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
||||
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;
|
||||
|
||||
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 8, 0, argsbuf);
|
||||
if (!args) {
|
||||
goto exit;
|
||||
}
|
||||
file = args[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (args[1]) {
|
||||
if (!PyUnicode_Check(args[1])) {
|
||||
_PyArg_BadArgument("open", "argument 'mode'", "str", args[1]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t mode_length;
|
||||
mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length);
|
||||
if (mode == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(mode) != (size_t)mode_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (args[2]) {
|
||||
if (PyFloat_Check(args[2])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
buffering = _PyLong_AsInt(args[2]);
|
||||
if (buffering == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (args[3]) {
|
||||
if (args[3] == Py_None) {
|
||||
encoding = NULL;
|
||||
}
|
||||
else if (PyUnicode_Check(args[3])) {
|
||||
Py_ssize_t encoding_length;
|
||||
encoding = PyUnicode_AsUTF8AndSize(args[3], &encoding_length);
|
||||
if (encoding == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(encoding) != (size_t)encoding_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("open", "argument 'encoding'", "str or None", args[3]);
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (args[4]) {
|
||||
if (args[4] == Py_None) {
|
||||
errors = NULL;
|
||||
}
|
||||
else if (PyUnicode_Check(args[4])) {
|
||||
Py_ssize_t errors_length;
|
||||
errors = PyUnicode_AsUTF8AndSize(args[4], &errors_length);
|
||||
if (errors == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(errors) != (size_t)errors_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("open", "argument 'errors'", "str or None", args[4]);
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (args[5]) {
|
||||
if (args[5] == Py_None) {
|
||||
newline = NULL;
|
||||
}
|
||||
else if (PyUnicode_Check(args[5])) {
|
||||
Py_ssize_t newline_length;
|
||||
newline = PyUnicode_AsUTF8AndSize(args[5], &newline_length);
|
||||
if (newline == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(newline) != (size_t)newline_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("open", "argument 'newline'", "str or None", args[5]);
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (args[6]) {
|
||||
if (PyFloat_Check(args[6])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
closefd = _PyLong_AsInt(args[6]);
|
||||
if (closefd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
opener = args[7];
|
||||
skip_optional_pos:
|
||||
return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_open_code__doc__,
|
||||
"open_code($module, /, path)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Opens the provided file with the intent to import the contents.\n"
|
||||
"\n"
|
||||
"This may perform extra validation beyond open(), but is otherwise interchangeable\n"
|
||||
"with calling open(path, \'rb\').");
|
||||
|
||||
#define _IO_OPEN_CODE_METHODDEF \
|
||||
{"open_code", (PyCFunction)(void(*)(void))_io_open_code, METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_open_code_impl(PyObject *module, PyObject *path);
|
||||
|
||||
static PyObject *
|
||||
_io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"path", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "open_code", 0};
|
||||
PyObject *argsbuf[1];
|
||||
PyObject *path;
|
||||
|
||||
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
||||
if (!args) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyUnicode_Check(args[0])) {
|
||||
_PyArg_BadArgument("open_code", "argument 'path'", "str", args[0]);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(args[0]) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
path = args[0];
|
||||
return_value = _io_open_code_impl(module, path);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=3df6bc6d91697545 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,675 @@
|
||||
/*[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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
|
||||
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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg);
|
||||
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)(void(*)(void))_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_peek_impl(buffered *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_peek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
size = ival;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io__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)(void(*)(void))_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_read_impl(buffered *self, Py_ssize_t n);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t n = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io__Buffered_read_impl(self, n);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io__Buffered_read1__doc__,
|
||||
"read1($self, size=-1, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _IO__BUFFERED_READ1_METHODDEF \
|
||||
{"read1", (PyCFunction)(void(*)(void))_io__Buffered_read1, METH_FASTCALL, _io__Buffered_read1__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t n = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
n = ival;
|
||||
}
|
||||
skip_optional:
|
||||
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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
|
||||
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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg);
|
||||
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)(void(*)(void))_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_readline(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
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)(void(*)(void))_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *targetobj;
|
||||
int whence = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
targetobj = args[0];
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
whence = _PyLong_AsInt(args[1]);
|
||||
if (whence == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io__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)(void(*)(void))_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_truncate_impl(buffered *self, PyObject *pos);
|
||||
|
||||
static PyObject *
|
||||
_io__Buffered_truncate(buffered *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *pos = Py_None;
|
||||
|
||||
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
pos = args[0];
|
||||
skip_optional:
|
||||
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 const char * const _keywords[] = {"raw", "buffer_size", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "BufferedReader", 0};
|
||||
PyObject *argsbuf[2];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *raw;
|
||||
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
raw = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (PyFloat_Check(fastargs[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(fastargs[1]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
buffer_size = ival;
|
||||
}
|
||||
skip_optional_pos:
|
||||
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 const char * const _keywords[] = {"raw", "buffer_size", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "BufferedWriter", 0};
|
||||
PyObject *argsbuf[2];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *raw;
|
||||
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
raw = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (PyFloat_Check(fastargs[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(fastargs[1]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
buffer_size = ival;
|
||||
}
|
||||
skip_optional_pos:
|
||||
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 (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
|
||||
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_IS_TYPE(self, &PyBufferedRWPair_Type) &&
|
||||
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
|
||||
goto exit;
|
||||
}
|
||||
if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) {
|
||||
goto exit;
|
||||
}
|
||||
reader = PyTuple_GET_ITEM(args, 0);
|
||||
writer = PyTuple_GET_ITEM(args, 1);
|
||||
if (PyTuple_GET_SIZE(args) < 3) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(PyTuple_GET_ITEM(args, 2))) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 2));
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
buffer_size = ival;
|
||||
}
|
||||
skip_optional:
|
||||
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 const char * const _keywords[] = {"raw", "buffer_size", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "BufferedRandom", 0};
|
||||
PyObject *argsbuf[2];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *raw;
|
||||
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
raw = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (PyFloat_Check(fastargs[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(fastargs[1]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
buffer_size = ival;
|
||||
}
|
||||
skip_optional_pos:
|
||||
return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=7d9ad40c95bdd808 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,518 @@
|
||||
/*[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=-1, /)\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)(void(*)(void))_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_read_impl(bytesio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_read(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_BytesIO_read_impl(self, size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_BytesIO_read1__doc__,
|
||||
"read1($self, size=-1, /)\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)(void(*)(void))_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_read1(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_BytesIO_read1_impl(self, size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_BytesIO_readline__doc__,
|
||||
"readline($self, size=-1, /)\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)(void(*)(void))_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_readline(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_BytesIO_readline_impl(self, size);
|
||||
|
||||
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)(void(*)(void))_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_readlines(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *arg = Py_None;
|
||||
|
||||
if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
arg = args[0];
|
||||
skip_optional:
|
||||
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 bytes into buffer.\n"
|
||||
"\n"
|
||||
"Returns number of bytes read (0 for EOF), or None if the object\n"
|
||||
"is set not to block and 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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
|
||||
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)(void(*)(void))_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_BytesIO_truncate(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = self->pos;
|
||||
|
||||
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_BytesIO_truncate_impl(self, size);
|
||||
|
||||
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)(void(*)(void))_io_BytesIO_seek, METH_FASTCALL, _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 *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t pos;
|
||||
int whence = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
pos = ival;
|
||||
}
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
whence = _PyLong_AsInt(args[1]);
|
||||
if (whence == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_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 const char * const _keywords[] = {"initial_bytes", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "BytesIO", 0};
|
||||
PyObject *argsbuf[1];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
|
||||
PyObject *initvalue = NULL;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
initvalue = fastargs[0];
|
||||
skip_optional_pos:
|
||||
return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=4ec2506def9c8eb9 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,450 @@
|
||||
/*[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 const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "FileIO", 0};
|
||||
PyObject *argsbuf[4];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *nameobj;
|
||||
const char *mode = "r";
|
||||
int closefd = 1;
|
||||
PyObject *opener = Py_None;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
nameobj = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (fastargs[1]) {
|
||||
if (!PyUnicode_Check(fastargs[1])) {
|
||||
_PyArg_BadArgument("FileIO", "argument 'mode'", "str", fastargs[1]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t mode_length;
|
||||
mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length);
|
||||
if (mode == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(mode) != (size_t)mode_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (fastargs[2]) {
|
||||
if (PyFloat_Check(fastargs[2])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
closefd = _PyLong_AsInt(fastargs[2]);
|
||||
if (closefd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
opener = fastargs[3];
|
||||
skip_optional_pos:
|
||||
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 (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
|
||||
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)(void(*)(void))_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_read_impl(fileio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_read(fileio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
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 buffer b to file, return number of bytes written.\n"
|
||||
"\n"
|
||||
"Only makes one system call, so not all of the data may be written.\n"
|
||||
"The number of bytes actually written is returned. 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 (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
|
||||
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)(void(*)(void))_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_seek(fileio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *pos;
|
||||
int whence = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
pos = args[0];
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
whence = _PyLong_AsInt(args[1]);
|
||||
if (whence == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_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)(void(*)(void))_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_truncate_impl(fileio *self, PyObject *posobj);
|
||||
|
||||
static PyObject *
|
||||
_io_FileIO_truncate(fileio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *posobj = Py_None;
|
||||
|
||||
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
posobj = args[0];
|
||||
skip_optional:
|
||||
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=e7682d0a3264d284 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,318 @@
|
||||
/*[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 OSError.\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 OSError.");
|
||||
|
||||
#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 OSError.");
|
||||
|
||||
#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"
|
||||
"OSError 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)(void(*)(void))_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit);
|
||||
|
||||
static PyObject *
|
||||
_io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t limit = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
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)(void(*)(void))_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint);
|
||||
|
||||
static PyObject *
|
||||
_io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t hint = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io__IOBase_readlines_impl(self, hint);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io__IOBase_writelines__doc__,
|
||||
"writelines($self, lines, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Write a list of lines to stream.\n"
|
||||
"\n"
|
||||
"Line separators are not added, so it is usual for each of the\n"
|
||||
"lines provided to have a line separator at the end.");
|
||||
|
||||
#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)(void(*)(void))_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n);
|
||||
|
||||
static PyObject *
|
||||
_io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t n = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
n = ival;
|
||||
}
|
||||
skip_optional:
|
||||
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=61b6ea7153ef9940 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,351 @@
|
||||
/*[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=-1, /)\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)(void(*)(void))_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_read_impl(stringio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_read(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_StringIO_read_impl(self, size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_StringIO_readline__doc__,
|
||||
"readline($self, size=-1, /)\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)(void(*)(void))_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_readline_impl(stringio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_StringIO_readline_impl(self, size);
|
||||
|
||||
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)(void(*)(void))_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_truncate_impl(stringio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = self->pos;
|
||||
|
||||
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_StringIO_truncate_impl(self, size);
|
||||
|
||||
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)(void(*)(void))_io_StringIO_seek, METH_FASTCALL, _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 *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t pos;
|
||||
int whence = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
pos = ival;
|
||||
}
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
whence = _PyLong_AsInt(args[1]);
|
||||
if (whence == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_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 const char * const _keywords[] = {"initial_value", "newline", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "StringIO", 0};
|
||||
PyObject *argsbuf[2];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
|
||||
PyObject *value = NULL;
|
||||
PyObject *newline_obj = NULL;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (fastargs[0]) {
|
||||
value = fastargs[0];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
newline_obj = fastargs[1];
|
||||
skip_optional_pos:
|
||||
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=7aad5ab2e64a25b8 input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,704 @@
|
||||
/*[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 const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "IncrementalNewlineDecoder", 0};
|
||||
PyObject *argsbuf[3];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
|
||||
PyObject *decoder;
|
||||
int translate;
|
||||
PyObject *errors = NULL;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
decoder = fastargs[0];
|
||||
if (PyFloat_Check(fastargs[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
translate = _PyLong_AsInt(fastargs[1]);
|
||||
if (translate == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
errors = fastargs[2];
|
||||
skip_optional_pos:
|
||||
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)(void(*)(void))_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|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 *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"input", "final", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
|
||||
PyObject *argsbuf[2];
|
||||
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
||||
PyObject *input;
|
||||
int final = 0;
|
||||
|
||||
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
|
||||
if (!args) {
|
||||
goto exit;
|
||||
}
|
||||
input = args[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
final = _PyLong_AsInt(args[1]);
|
||||
if (final == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional_pos:
|
||||
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, PyObject *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 const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "TextIOWrapper", 0};
|
||||
PyObject *argsbuf[6];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *buffer;
|
||||
const char *encoding = NULL;
|
||||
PyObject *errors = Py_None;
|
||||
const char *newline = NULL;
|
||||
int line_buffering = 0;
|
||||
int write_through = 0;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
buffer = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (fastargs[1]) {
|
||||
if (fastargs[1] == Py_None) {
|
||||
encoding = NULL;
|
||||
}
|
||||
else if (PyUnicode_Check(fastargs[1])) {
|
||||
Py_ssize_t encoding_length;
|
||||
encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
|
||||
if (encoding == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(encoding) != (size_t)encoding_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]);
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (fastargs[2]) {
|
||||
errors = fastargs[2];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (fastargs[3]) {
|
||||
if (fastargs[3] == Py_None) {
|
||||
newline = NULL;
|
||||
}
|
||||
else if (PyUnicode_Check(fastargs[3])) {
|
||||
Py_ssize_t newline_length;
|
||||
newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length);
|
||||
if (newline == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(newline) != (size_t)newline_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]);
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (fastargs[4]) {
|
||||
if (PyFloat_Check(fastargs[4])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
line_buffering = _PyLong_AsInt(fastargs[4]);
|
||||
if (line_buffering == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (PyFloat_Check(fastargs[5])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
write_through = _PyLong_AsInt(fastargs[5]);
|
||||
if (write_through == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional_pos:
|
||||
return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__,
|
||||
"reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n"
|
||||
" line_buffering=None, write_through=None)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Reconfigure the text stream with new parameters.\n"
|
||||
"\n"
|
||||
"This also does an implicit stream flush.");
|
||||
|
||||
#define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \
|
||||
{"reconfigure", (PyCFunction)(void(*)(void))_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
|
||||
PyObject *errors, PyObject *newline_obj,
|
||||
PyObject *line_buffering_obj,
|
||||
PyObject *write_through_obj);
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "reconfigure", 0};
|
||||
PyObject *argsbuf[5];
|
||||
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
|
||||
PyObject *encoding = Py_None;
|
||||
PyObject *errors = Py_None;
|
||||
PyObject *newline_obj = NULL;
|
||||
PyObject *line_buffering_obj = Py_None;
|
||||
PyObject *write_through_obj = Py_None;
|
||||
|
||||
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
|
||||
if (!args) {
|
||||
goto exit;
|
||||
}
|
||||
if (!noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
if (args[0]) {
|
||||
encoding = args[0];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
}
|
||||
if (args[1]) {
|
||||
errors = args[1];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
}
|
||||
if (args[2]) {
|
||||
newline_obj = args[2];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
}
|
||||
if (args[3]) {
|
||||
line_buffering_obj = args[3];
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
}
|
||||
write_through_obj = args[4];
|
||||
skip_optional_kwonly:
|
||||
return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj);
|
||||
|
||||
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 (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("write", "argument", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
text = arg;
|
||||
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)(void(*)(void))_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t n = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_TextIOWrapper_read_impl(self, n);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
|
||||
"readline($self, size=-1, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \
|
||||
{"readline", (PyCFunction)(void(*)(void))_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[0])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(args[0]);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
size = ival;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_TextIOWrapper_readline_impl(self, size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
|
||||
"seek($self, cookie, whence=0, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \
|
||||
{"seek", (PyCFunction)(void(*)(void))_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *cookieObj;
|
||||
int whence = 0;
|
||||
|
||||
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
cookieObj = args[0];
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (PyFloat_Check(args[1])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
whence = _PyLong_AsInt(args[1]);
|
||||
if (whence == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
|
||||
|
||||
exit:
|
||||
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)(void(*)(void))_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *pos = Py_None;
|
||||
|
||||
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
pos = args[0];
|
||||
skip_optional:
|
||||
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=b1bae4f4cdf6019e input=a9049054013a1b77]*/
|
||||
@ -0,0 +1,389 @@
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_close__doc__,
|
||||
"close($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Close the handle.\n"
|
||||
"\n"
|
||||
"A closed handle cannot be used for further I/O operations. close() may be\n"
|
||||
"called more than once without error.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF \
|
||||
{"close", (PyCFunction)_io__WindowsConsoleIO_close, METH_NOARGS, _io__WindowsConsoleIO_close__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_close_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_close(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_close_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO___init____doc__,
|
||||
"_WindowsConsoleIO(file, mode=\'r\', closefd=True, opener=None)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Open a console buffer by file descriptor.\n"
|
||||
"\n"
|
||||
"The mode can be \'rb\' (default), or \'wb\' for reading or writing bytes. All\n"
|
||||
"other mode characters will be ignored. Mode \'b\' will be assumed if it is\n"
|
||||
"omitted. The *opener* parameter is always ignored.");
|
||||
|
||||
static int
|
||||
_io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
|
||||
const char *mode, int closefd,
|
||||
PyObject *opener);
|
||||
|
||||
static int
|
||||
_io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
int return_value = -1;
|
||||
static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
|
||||
static _PyArg_Parser _parser = {NULL, _keywords, "_WindowsConsoleIO", 0};
|
||||
PyObject *argsbuf[4];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
PyObject *nameobj;
|
||||
const char *mode = "r";
|
||||
int closefd = 1;
|
||||
PyObject *opener = Py_None;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf);
|
||||
if (!fastargs) {
|
||||
goto exit;
|
||||
}
|
||||
nameobj = fastargs[0];
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
if (fastargs[1]) {
|
||||
if (!PyUnicode_Check(fastargs[1])) {
|
||||
_PyArg_BadArgument("_WindowsConsoleIO", "argument 'mode'", "str", fastargs[1]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t mode_length;
|
||||
mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length);
|
||||
if (mode == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(mode) != (size_t)mode_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
if (fastargs[2]) {
|
||||
if (PyFloat_Check(fastargs[2])) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
closefd = _PyLong_AsInt(fastargs[2]);
|
||||
if (closefd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
}
|
||||
opener = fastargs[3];
|
||||
skip_optional_pos:
|
||||
return_value = _io__WindowsConsoleIO___init___impl((winconsoleio *)self, nameobj, mode, closefd, opener);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_fileno__doc__,
|
||||
"fileno($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the underlying file descriptor (an integer).\n"
|
||||
"\n"
|
||||
"fileno is only set when a file descriptor is used to open\n"
|
||||
"one of the standard streams.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF \
|
||||
{"fileno", (PyCFunction)_io__WindowsConsoleIO_fileno, METH_NOARGS, _io__WindowsConsoleIO_fileno__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_fileno_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_fileno(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_fileno_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_readable__doc__,
|
||||
"readable($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"True if console is an input buffer.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF \
|
||||
{"readable", (PyCFunction)_io__WindowsConsoleIO_readable, METH_NOARGS, _io__WindowsConsoleIO_readable__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readable_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_readable_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_writable__doc__,
|
||||
"writable($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"True if console is an output buffer.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF \
|
||||
{"writable", (PyCFunction)_io__WindowsConsoleIO_writable, METH_NOARGS, _io__WindowsConsoleIO_writable__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_writable_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_writable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_writable_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_readinto__doc__,
|
||||
"readinto($self, buffer, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Same as RawIOBase.readinto().");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF \
|
||||
{"readinto", (PyCFunction)_io__WindowsConsoleIO_readinto, METH_O, _io__WindowsConsoleIO_readinto__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readinto_impl(winconsoleio *self, Py_buffer *buffer);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
|
||||
|
||||
exit:
|
||||
/* Cleanup for buffer */
|
||||
if (buffer.obj) {
|
||||
PyBuffer_Release(&buffer);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_readall__doc__,
|
||||
"readall($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Read all data from the console, returned as bytes.\n"
|
||||
"\n"
|
||||
"Return an empty bytes object at EOF.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF \
|
||||
{"readall", (PyCFunction)_io__WindowsConsoleIO_readall, METH_NOARGS, _io__WindowsConsoleIO_readall__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readall_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_readall(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_readall_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_read__doc__,
|
||||
"read($self, size=-1, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Read at most size bytes, returned as bytes.\n"
|
||||
"\n"
|
||||
"Only makes one system call when size is a positive integer,\n"
|
||||
"so less data may be returned than requested.\n"
|
||||
"Return an empty bytes object at EOF.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_READ_METHODDEF \
|
||||
{"read", (PyCFunction)(void(*)(void))_io__WindowsConsoleIO_read, METH_FASTCALL, _io__WindowsConsoleIO_read__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_read_impl(winconsoleio *self, Py_ssize_t size);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_read(winconsoleio *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = _io__WindowsConsoleIO_read_impl(self, size);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_write__doc__,
|
||||
"write($self, b, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Write buffer b to file, return number of bytes written.\n"
|
||||
"\n"
|
||||
"Only makes one system call, so not all of the data may be written.\n"
|
||||
"The number of bytes actually written is returned.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF \
|
||||
{"write", (PyCFunction)_io__WindowsConsoleIO_write, METH_O, _io__WindowsConsoleIO_write__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer b = {NULL, NULL};
|
||||
|
||||
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
|
||||
|
||||
exit:
|
||||
/* Cleanup for b */
|
||||
if (b.obj) {
|
||||
PyBuffer_Release(&b);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
|
||||
PyDoc_STRVAR(_io__WindowsConsoleIO_isatty__doc__,
|
||||
"isatty($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Always True.");
|
||||
|
||||
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF \
|
||||
{"isatty", (PyCFunction)_io__WindowsConsoleIO_isatty, METH_NOARGS, _io__WindowsConsoleIO_isatty__doc__},
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_isatty_impl(winconsoleio *self);
|
||||
|
||||
static PyObject *
|
||||
_io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _io__WindowsConsoleIO_isatty_impl(self);
|
||||
}
|
||||
|
||||
#endif /* defined(MS_WINDOWS) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_FILENO_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READABLE_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READINTO_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READALL_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_READ_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_READ_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READ_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITE_METHODDEF) */
|
||||
|
||||
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
|
||||
/*[clinic end generated code: output=f5b8860a658a001a input=a9049054013a1b77]*/
|
||||
Reference in New Issue
Block a user