mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #20175: Converted the _io module to Argument Clinic.
This commit is contained in:
parent
7f90cba7f3
commit
f24131ff31
16 changed files with 4209 additions and 1372 deletions
|
@ -11,6 +11,20 @@
|
|||
#include "structmember.h"
|
||||
#include "_iomodule.h"
|
||||
|
||||
/*[clinic input]
|
||||
module _io
|
||||
class _io.IncrementalNewlineDecoder "nldecoder_object *" "&PyIncrementalNewlineDecoder_Type"
|
||||
class _io.TextIOWrapper "textio *" "&TextIOWrapper_TYpe"
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2097a4fc85670c26]*/
|
||||
|
||||
/*[python input]
|
||||
class io_ssize_t_converter(CConverter):
|
||||
type = 'Py_ssize_t'
|
||||
converter = '_PyIO_ConvertSsize_t'
|
||||
[python start generated code]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=d0a811d3cbfd1b33]*/
|
||||
|
||||
_Py_IDENTIFIER(close);
|
||||
_Py_IDENTIFIER(_dealloc_warn);
|
||||
_Py_IDENTIFIER(decode);
|
||||
|
@ -210,16 +224,6 @@ PyTypeObject PyTextIOBase_Type = {
|
|||
|
||||
/* IncrementalNewlineDecoder */
|
||||
|
||||
PyDoc_STRVAR(incrementalnewlinedecoder_doc,
|
||||
"Codec used when reading a file in universal newlines mode. It wraps\n"
|
||||
"another incremental decoder, translating \\r\\n and \\r into \\n. It also\n"
|
||||
"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.\n"
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *decoder;
|
||||
|
@ -229,19 +233,28 @@ typedef struct {
|
|||
unsigned int seennl: 3;
|
||||
} nldecoder_object;
|
||||
|
||||
/*[clinic input]
|
||||
_io.IncrementalNewlineDecoder.__init__
|
||||
decoder: object
|
||||
translate: int
|
||||
errors: object(c_default="NULL") = "strict"
|
||||
|
||||
Codec used when reading a file in universal newlines mode.
|
||||
|
||||
It wraps another incremental decoder, translating \r\n and \r into \n.
|
||||
It also records the types of newlines encountered. When used with
|
||||
translate=False, it ensures that the newline sequence is returned in
|
||||
one piece. When used with decoder=None, it expects unicode strings as
|
||||
decode input and translates newlines without first invoking an external
|
||||
decoder.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static int
|
||||
incrementalnewlinedecoder_init(nldecoder_object *self,
|
||||
PyObject *args, PyObject *kwds)
|
||||
_io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
|
||||
PyObject *decoder, int translate,
|
||||
PyObject *errors)
|
||||
/*[clinic end generated code: output=fbd04d443e764ec2 input=89db6b19c6b126bf]*/
|
||||
{
|
||||
PyObject *decoder;
|
||||
int translate;
|
||||
PyObject *errors = NULL;
|
||||
char *kwlist[] = {"decoder", "translate", "errors", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oi|O:IncrementalNewlineDecoder",
|
||||
kwlist, &decoder, &translate, &errors))
|
||||
return -1;
|
||||
|
||||
self->decoder = decoder;
|
||||
Py_INCREF(decoder);
|
||||
|
||||
|
@ -495,22 +508,27 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
incrementalnewlinedecoder_decode(nldecoder_object *self,
|
||||
PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char *kwlist[] = {"input", "final", NULL};
|
||||
PyObject *input;
|
||||
int final = 0;
|
||||
/*[clinic input]
|
||||
_io.IncrementalNewlineDecoder.decode
|
||||
input: object
|
||||
final: int(c_default="0") = False
|
||||
[clinic start generated code]*/
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|i:IncrementalNewlineDecoder",
|
||||
kwlist, &input, &final))
|
||||
return NULL;
|
||||
static PyObject *
|
||||
_io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
|
||||
PyObject *input, int final)
|
||||
/*[clinic end generated code: output=0d486755bb37a66e input=d65677385bfd6827]*/
|
||||
{
|
||||
return _PyIncrementalNewlineDecoder_decode((PyObject *) self, input, final);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.IncrementalNewlineDecoder.getstate
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
incrementalnewlinedecoder_getstate(nldecoder_object *self, PyObject *args)
|
||||
_io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self)
|
||||
/*[clinic end generated code: output=f0d2c9c136f4e0d0 input=f8ff101825e32e7f]*/
|
||||
{
|
||||
PyObject *buffer;
|
||||
unsigned PY_LONG_LONG flag;
|
||||
|
@ -537,8 +555,16 @@ incrementalnewlinedecoder_getstate(nldecoder_object *self, PyObject *args)
|
|||
return Py_BuildValue("NK", buffer, flag);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.IncrementalNewlineDecoder.setstate
|
||||
state: object
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
incrementalnewlinedecoder_setstate(nldecoder_object *self, PyObject *state)
|
||||
_io_IncrementalNewlineDecoder_setstate(nldecoder_object *self,
|
||||
PyObject *state)
|
||||
/*[clinic end generated code: output=c10c622508b576cb input=c53fb505a76dbbe2]*/
|
||||
{
|
||||
PyObject *buffer;
|
||||
unsigned PY_LONG_LONG flag;
|
||||
|
@ -556,8 +582,13 @@ incrementalnewlinedecoder_setstate(nldecoder_object *self, PyObject *state)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.IncrementalNewlineDecoder.reset
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
incrementalnewlinedecoder_reset(nldecoder_object *self, PyObject *args)
|
||||
_io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self)
|
||||
/*[clinic end generated code: output=32fa40c7462aa8ff input=728678ddaea776df]*/
|
||||
{
|
||||
self->seennl = 0;
|
||||
self->pendingcr = 0;
|
||||
|
@ -591,95 +622,8 @@ incrementalnewlinedecoder_newlines_get(nldecoder_object *self, void *context)
|
|||
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef incrementalnewlinedecoder_methods[] = {
|
||||
{"decode", (PyCFunction)incrementalnewlinedecoder_decode, METH_VARARGS|METH_KEYWORDS},
|
||||
{"getstate", (PyCFunction)incrementalnewlinedecoder_getstate, METH_NOARGS},
|
||||
{"setstate", (PyCFunction)incrementalnewlinedecoder_setstate, METH_O},
|
||||
{"reset", (PyCFunction)incrementalnewlinedecoder_reset, METH_NOARGS},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static PyGetSetDef incrementalnewlinedecoder_getset[] = {
|
||||
{"newlines", (getter)incrementalnewlinedecoder_newlines_get, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
PyTypeObject PyIncrementalNewlineDecoder_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_io.IncrementalNewlineDecoder", /*tp_name*/
|
||||
sizeof(nldecoder_object), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)incrementalnewlinedecoder_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare */
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
0, /*tp_call*/
|
||||
0, /*tp_str*/
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||
incrementalnewlinedecoder_doc, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /*tp_weaklistoffset*/
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
incrementalnewlinedecoder_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
incrementalnewlinedecoder_getset, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
(initproc)incrementalnewlinedecoder_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
};
|
||||
|
||||
|
||||
/* TextIOWrapper */
|
||||
|
||||
PyDoc_STRVAR(textiowrapper_doc,
|
||||
"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."
|
||||
);
|
||||
|
||||
typedef PyObject *
|
||||
(*encodefunc_t)(PyObject *, PyObject *);
|
||||
|
||||
|
@ -742,7 +686,6 @@ typedef struct
|
|||
PyObject *dict;
|
||||
} textio;
|
||||
|
||||
|
||||
/* A couple of specialized cases in order to bypass the slow incremental
|
||||
encoding methods for the most popular encodings. */
|
||||
|
||||
|
@ -843,28 +786,59 @@ static encodefuncentry encodefuncs[] = {
|
|||
};
|
||||
|
||||
|
||||
static int
|
||||
textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char *kwlist[] = {"buffer", "encoding", "errors",
|
||||
"newline", "line_buffering", "write_through",
|
||||
NULL};
|
||||
PyObject *buffer, *raw, *codec_info = NULL;
|
||||
char *encoding = NULL;
|
||||
char *errors = NULL;
|
||||
char *newline = NULL;
|
||||
int line_buffering = 0, write_through = 0;
|
||||
_PyIO_State *state = NULL;
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.__init__
|
||||
buffer: object
|
||||
encoding: str(nullable=True) = NULL
|
||||
errors: str(nullable=True) = NULL
|
||||
newline: str(nullable=True) = NULL
|
||||
line_buffering: int(c_default="0") = False
|
||||
write_through: int(c_default="0") = False
|
||||
|
||||
Character and line based layer over a BufferedIOBase object, buffer.
|
||||
|
||||
encoding gives the name of the encoding that the stream will be
|
||||
decoded or encoded with. It defaults to locale.getpreferredencoding(False).
|
||||
|
||||
errors determines the strictness of encoding and decoding (see
|
||||
help(codecs.Codec) or the documentation for codecs.register) and
|
||||
defaults to "strict".
|
||||
|
||||
newline controls how line endings are handled. It can be None, '',
|
||||
'\n', '\r', and '\r\n'. It works as follows:
|
||||
|
||||
* On input, if newline is None, universal newlines mode is
|
||||
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
|
||||
these are translated into '\n' before being returned to the
|
||||
caller. If it is '', universal newline mode is enabled, but line
|
||||
endings are returned to the caller untranslated. If it has any of
|
||||
the other legal values, input lines are only terminated by the given
|
||||
string, and the line ending is returned to the caller untranslated.
|
||||
|
||||
* On output, if newline is None, any '\n' characters written are
|
||||
translated to the system default line separator, os.linesep. If
|
||||
newline is '' or '\n', no translation takes place. If newline is any
|
||||
of the other legal values, any '\n' characters written are translated
|
||||
to the given string.
|
||||
|
||||
If line_buffering is True, a call to flush is implied when a call to
|
||||
write contains a newline character.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static int
|
||||
_io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
|
||||
const char *encoding, const char *errors,
|
||||
const char *newline, int line_buffering,
|
||||
int write_through)
|
||||
/*[clinic end generated code: output=56a83402ce2a8381 input=1f20decb8d54a4ec]*/
|
||||
{
|
||||
PyObject *raw, *codec_info = NULL;
|
||||
_PyIO_State *state = NULL;
|
||||
PyObject *res;
|
||||
int r;
|
||||
|
||||
self->ok = 0;
|
||||
self->detached = 0;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|zzzii:fileio",
|
||||
kwlist, &buffer, &encoding, &errors,
|
||||
&newline, &line_buffering, &write_through))
|
||||
return -1;
|
||||
|
||||
if (newline && newline[0] != '\0'
|
||||
&& !(newline[0] == '\n' && newline[1] == '\0')
|
||||
|
@ -1244,8 +1218,13 @@ textiowrapper_closed_get(textio *self, void *context);
|
|||
}
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.detach
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_detach(textio *self)
|
||||
_io_TextIOWrapper_detach_impl(textio *self)
|
||||
/*[clinic end generated code: output=7ba3715cd032d5f2 input=e5a71fbda9e1d9f9]*/
|
||||
{
|
||||
PyObject *buffer, *res;
|
||||
CHECK_ATTACHED(self);
|
||||
|
@ -1290,25 +1269,26 @@ _textiowrapper_writeflush(textio *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.write
|
||||
text: unicode
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_write(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_write_impl(textio *self, PyObject *text)
|
||||
/*[clinic end generated code: output=d2deb0d50771fcec input=fdf19153584a0e44]*/
|
||||
{
|
||||
PyObject *ret;
|
||||
PyObject *text; /* owned reference */
|
||||
PyObject *b;
|
||||
Py_ssize_t textlen;
|
||||
int haslf = 0;
|
||||
int needflush = 0, text_needflush = 0;
|
||||
|
||||
CHECK_ATTACHED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "U:write", &text)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PyUnicode_READY(text) == -1)
|
||||
return NULL;
|
||||
|
||||
CHECK_ATTACHED(self);
|
||||
CHECK_CLOSED(self);
|
||||
|
||||
if (self->encoder == NULL)
|
||||
|
@ -1557,17 +1537,19 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.read
|
||||
size as n: io_ssize_t = -1
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_read(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
|
||||
/*[clinic end generated code: output=7e651ce6cc6a25a6 input=8c09398424085cca]*/
|
||||
{
|
||||
Py_ssize_t n = -1;
|
||||
PyObject *result = NULL, *chunks = NULL;
|
||||
|
||||
CHECK_ATTACHED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O&:read", &_PyIO_ConvertSsize_t, &n))
|
||||
return NULL;
|
||||
|
||||
CHECK_CLOSED(self);
|
||||
|
||||
if (self->decoder == NULL)
|
||||
|
@ -1933,16 +1915,18 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_readline(textio *self, PyObject *args)
|
||||
{
|
||||
Py_ssize_t limit = -1;
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.readline
|
||||
size: Py_ssize_t = -1
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size)
|
||||
/*[clinic end generated code: output=344afa98804e8b25 input=56c7172483b36db6]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
if (!PyArg_ParseTuple(args, "|n:readline", &limit)) {
|
||||
return NULL;
|
||||
}
|
||||
return _textiowrapper_readline(self, limit);
|
||||
return _textiowrapper_readline(self, size);
|
||||
}
|
||||
|
||||
/* Seek and Tell */
|
||||
|
@ -2074,19 +2058,23 @@ _textiowrapper_encoder_setstate(textio *self, cookie_type *cookie)
|
|||
self, cookie->start_pos == 0 && cookie->dec_flags == 0);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.seek
|
||||
cookie as cookieObj: object
|
||||
whence: int = 0
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_seek(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
|
||||
/*[clinic end generated code: output=0a15679764e2d04d input=0458abeb3d7842be]*/
|
||||
{
|
||||
PyObject *cookieObj, *posobj;
|
||||
PyObject *posobj;
|
||||
cookie_type cookie;
|
||||
int whence = 0;
|
||||
PyObject *res;
|
||||
int cmp;
|
||||
|
||||
CHECK_ATTACHED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|i:seek", &cookieObj, &whence))
|
||||
return NULL;
|
||||
CHECK_CLOSED(self);
|
||||
|
||||
Py_INCREF(cookieObj);
|
||||
|
@ -2258,8 +2246,13 @@ textiowrapper_seek(textio *self, PyObject *args)
|
|||
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.tell
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_tell(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_tell_impl(textio *self)
|
||||
/*[clinic end generated code: output=4f168c08bf34ad5f input=9a2caf88c24f9ddf]*/
|
||||
{
|
||||
PyObject *res;
|
||||
PyObject *posobj = NULL;
|
||||
|
@ -2466,16 +2459,19 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.truncate
|
||||
pos: object = None
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_truncate(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos)
|
||||
/*[clinic end generated code: output=90ec2afb9bb7745f input=56ec8baa65aea377]*/
|
||||
{
|
||||
PyObject *pos = Py_None;
|
||||
PyObject *res;
|
||||
|
||||
CHECK_ATTACHED(self)
|
||||
if (!PyArg_ParseTuple(args, "|O:truncate", &pos)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_flush, NULL);
|
||||
if (res == NULL)
|
||||
|
@ -2540,36 +2536,61 @@ error:
|
|||
|
||||
/* Inquiries */
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.fileno
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_fileno(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_fileno_impl(textio *self)
|
||||
/*[clinic end generated code: output=21490a4c3da13e6c input=c488ca83d0069f9b]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
return _PyObject_CallMethodId(self->buffer, &PyId_fileno, NULL);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.seekable
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_seekable(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_seekable_impl(textio *self)
|
||||
/*[clinic end generated code: output=ab223dbbcffc0f00 input=8b005ca06e1fca13]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
return _PyObject_CallMethodId(self->buffer, &PyId_seekable, NULL);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.readable
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_readable(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_readable_impl(textio *self)
|
||||
/*[clinic end generated code: output=72ff7ba289a8a91b input=0704ea7e01b0d3eb]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
return _PyObject_CallMethodId(self->buffer, &PyId_readable, NULL);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.writable
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_writable(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_writable_impl(textio *self)
|
||||
/*[clinic end generated code: output=a728c71790d03200 input=c41740bc9d8636e8]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
return _PyObject_CallMethodId(self->buffer, &PyId_writable, NULL);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.isatty
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_isatty(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_isatty_impl(textio *self)
|
||||
/*[clinic end generated code: output=12be1a35bace882e input=fb68d9f2c99bbfff]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
return _PyObject_CallMethodId(self->buffer, &PyId_isatty, NULL);
|
||||
|
@ -2583,8 +2604,13 @@ textiowrapper_getstate(textio *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.flush
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_flush(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_flush_impl(textio *self)
|
||||
/*[clinic end generated code: output=59de9165f9c2e4d2 input=928c60590694ab85]*/
|
||||
{
|
||||
CHECK_ATTACHED(self);
|
||||
CHECK_CLOSED(self);
|
||||
|
@ -2594,8 +2620,13 @@ textiowrapper_flush(textio *self, PyObject *args)
|
|||
return _PyObject_CallMethodId(self->buffer, &PyId_flush, NULL);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_io.TextIOWrapper.close
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
textiowrapper_close(textio *self, PyObject *args)
|
||||
_io_TextIOWrapper_close_impl(textio *self)
|
||||
/*[clinic end generated code: output=056ccf8b4876e4f4 input=9c2114315eae1948]*/
|
||||
{
|
||||
PyObject *res;
|
||||
int r;
|
||||
|
@ -2739,24 +2770,81 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PyMethodDef textiowrapper_methods[] = {
|
||||
{"detach", (PyCFunction)textiowrapper_detach, METH_NOARGS},
|
||||
{"write", (PyCFunction)textiowrapper_write, METH_VARARGS},
|
||||
{"read", (PyCFunction)textiowrapper_read, METH_VARARGS},
|
||||
{"readline", (PyCFunction)textiowrapper_readline, METH_VARARGS},
|
||||
{"flush", (PyCFunction)textiowrapper_flush, METH_NOARGS},
|
||||
{"close", (PyCFunction)textiowrapper_close, METH_NOARGS},
|
||||
#include "clinic/textio.c.h"
|
||||
|
||||
{"fileno", (PyCFunction)textiowrapper_fileno, METH_NOARGS},
|
||||
{"seekable", (PyCFunction)textiowrapper_seekable, METH_NOARGS},
|
||||
{"readable", (PyCFunction)textiowrapper_readable, METH_NOARGS},
|
||||
{"writable", (PyCFunction)textiowrapper_writable, METH_NOARGS},
|
||||
{"isatty", (PyCFunction)textiowrapper_isatty, METH_NOARGS},
|
||||
static PyMethodDef incrementalnewlinedecoder_methods[] = {
|
||||
_IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF
|
||||
_IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF
|
||||
_IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF
|
||||
_IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static PyGetSetDef incrementalnewlinedecoder_getset[] = {
|
||||
{"newlines", (getter)incrementalnewlinedecoder_newlines_get, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
PyTypeObject PyIncrementalNewlineDecoder_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_io.IncrementalNewlineDecoder", /*tp_name*/
|
||||
sizeof(nldecoder_object), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)incrementalnewlinedecoder_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare */
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
0, /*tp_call*/
|
||||
0, /*tp_str*/
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||
_io_IncrementalNewlineDecoder___init____doc__, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /*tp_weaklistoffset*/
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
incrementalnewlinedecoder_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
incrementalnewlinedecoder_getset, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
_io_IncrementalNewlineDecoder___init__, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
};
|
||||
|
||||
|
||||
static PyMethodDef textiowrapper_methods[] = {
|
||||
_IO_TEXTIOWRAPPER_DETACH_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_WRITE_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_READ_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_READLINE_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_FLUSH_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_CLOSE_METHODDEF
|
||||
|
||||
_IO_TEXTIOWRAPPER_FILENO_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_READABLE_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_WRITABLE_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_ISATTY_METHODDEF
|
||||
{"__getstate__", (PyCFunction)textiowrapper_getstate, METH_NOARGS},
|
||||
|
||||
{"seek", (PyCFunction)textiowrapper_seek, METH_VARARGS},
|
||||
{"tell", (PyCFunction)textiowrapper_tell, METH_NOARGS},
|
||||
{"truncate", (PyCFunction)textiowrapper_truncate, METH_VARARGS},
|
||||
_IO_TEXTIOWRAPPER_SEEK_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_TELL_METHODDEF
|
||||
_IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -2802,7 +2890,7 @@ PyTypeObject PyTextIOWrapper_Type = {
|
|||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
|
||||
| Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/
|
||||
textiowrapper_doc, /* tp_doc */
|
||||
_io_TextIOWrapper___init____doc__, /* tp_doc */
|
||||
(traverseproc)textiowrapper_traverse, /* tp_traverse */
|
||||
(inquiry)textiowrapper_clear, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
|
@ -2817,7 +2905,7 @@ PyTypeObject PyTextIOWrapper_Type = {
|
|||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
offsetof(textio, dict), /*tp_dictoffset*/
|
||||
(initproc)textiowrapper_init, /* tp_init */
|
||||
_io_TextIOWrapper___init__, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
0, /* tp_free */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue