summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-09 00:07:03 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-09 00:07:03 (GMT)
commitc4c0eaebbff47a70bcdbc97d9b57e57b977efb5d (patch)
treeee6ed5cd1fc352607a41a9acffef867e5aa5bf51 /Modules
parentf2b55fb5ee0374babd770dd5aabad5045a1f78dc (diff)
downloadcpython-c4c0eaebbff47a70bcdbc97d9b57e57b977efb5d.zip
cpython-c4c0eaebbff47a70bcdbc97d9b57e57b977efb5d.tar.gz
cpython-c4c0eaebbff47a70bcdbc97d9b57e57b977efb5d.tar.bz2
give TextIOWrapper a repr that tells you the encoding
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_textio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_textio.c b/Modules/_textio.c
index c70b1dd..a61e6bc 100644
--- a/Modules/_textio.c
+++ b/Modules/_textio.c
@@ -2171,6 +2171,14 @@ TextIOWrapper_truncate(PyTextIOWrapperObject *self, PyObject *args)
return PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_truncate, NULL);
}
+static PyObject *
+TextIOWrapper_repr(PyTextIOWrapperObject *self)
+{
+ CHECK_INITIALIZED(self);
+ return PyUnicode_FromFormat("<TextIOWrapper encoding=%S>", self->encoding);
+}
+
+
/* Inquiries */
static PyObject *
@@ -2372,9 +2380,9 @@ PyTypeObject PyTextIOWrapper_Type = {
(destructor)TextIOWrapper_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
- 0, /*tp_setattr*/
+ 0, /*tps_etattr*/
0, /*tp_compare */
- 0, /*tp_repr*/
+ (reprfunc)TextIOWrapper_repr,/*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/