mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
give the C implementation of TextIOWrapper the errors property #6217
This commit is contained in:
parent
3bbbf18a38
commit
0926ad1f05
7 changed files with 50 additions and 26 deletions
|
@ -660,22 +660,6 @@ stringio_closed(StringIOObject *self, void *context)
|
|||
return PyBool_FromLong(self->closed);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
stringio_encoding(StringIOObject *self, void *context)
|
||||
{
|
||||
CHECK_INITIALIZED(self);
|
||||
CHECK_CLOSED(self);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
stringio_errors(StringIOObject *self, void *context)
|
||||
{
|
||||
CHECK_INITIALIZED(self);
|
||||
CHECK_CLOSED(self);
|
||||
return PyUnicode_FromString("strict");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
stringio_line_buffering(StringIOObject *self, void *context)
|
||||
{
|
||||
|
@ -720,8 +704,6 @@ static PyGetSetDef stringio_getset[] = {
|
|||
will be found.
|
||||
*/
|
||||
{"buffer", (getter)stringio_buffer, NULL, NULL},
|
||||
{"encoding", (getter)stringio_encoding, NULL, NULL},
|
||||
{"errors", (getter)stringio_errors, NULL, NULL},
|
||||
{"line_buffering", (getter)stringio_line_buffering, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
|
|
@ -104,6 +104,18 @@ TextIOBase_newlines_get(PyObject *self, void *context)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(TextIOBase_errors_doc,
|
||||
"The error setting of the decoder or encoder.\n"
|
||||
"\n"
|
||||
"Subclasses should override.\n"
|
||||
);
|
||||
|
||||
static PyObject *
|
||||
TextIOBase_errors_get(PyObject *self, void *context)
|
||||
{
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef TextIOBase_methods[] = {
|
||||
{"detach", (PyCFunction)TextIOBase_detach, METH_NOARGS, TextIOBase_detach_doc},
|
||||
|
@ -116,6 +128,7 @@ static PyMethodDef TextIOBase_methods[] = {
|
|||
static PyGetSetDef TextIOBase_getset[] = {
|
||||
{"encoding", (getter)TextIOBase_encoding_get, NULL, TextIOBase_encoding_doc},
|
||||
{"newlines", (getter)TextIOBase_newlines_get, NULL, TextIOBase_newlines_doc},
|
||||
{"errors", (getter)TextIOBase_errors_get, NULL, TextIOBase_errors_doc},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
@ -2461,6 +2474,13 @@ TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context)
|
|||
return res;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
TextIOWrapper_errors_get(PyTextIOWrapperObject *self, void *context)
|
||||
{
|
||||
CHECK_INITIALIZED(self);
|
||||
return PyUnicode_FromString(PyBytes_AS_STRING(self->errors));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
TextIOWrapper_chunk_size_get(PyTextIOWrapperObject *self, void *context)
|
||||
{
|
||||
|
@ -2519,6 +2539,7 @@ static PyGetSetDef TextIOWrapper_getset[] = {
|
|||
/* {"mode", (getter)TextIOWrapper_mode_get, NULL, NULL},
|
||||
*/
|
||||
{"newlines", (getter)TextIOWrapper_newlines_get, NULL, NULL},
|
||||
{"errors", (getter)TextIOWrapper_errors_get, NULL, NULL},
|
||||
{"_CHUNK_SIZE", (getter)TextIOWrapper_chunk_size_get,
|
||||
(setter)TextIOWrapper_chunk_size_set, NULL},
|
||||
{NULL}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue