diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2010-12-18 14:59:43 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2010-12-18 14:59:43 (GMT) |
commit | ac53ab64a648f512f4a232567f096b8fb14287bf (patch) | |
tree | 33dbd8d10706568779ea848a7f4e4972fecb95d3 /Objects/descrobject.c | |
parent | 197c9c945e127199d0b0966d33abe00f512d0e8b (diff) | |
download | cpython-ac53ab64a648f512f4a232567f096b8fb14287bf.zip cpython-ac53ab64a648f512f4a232567f096b8fb14287bf.tar.gz cpython-ac53ab64a648f512f4a232567f096b8fb14287bf.tar.bz2 |
#5587: add a repr to dict_proxy objects. Patch by David Stanek and Daniel Urban.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r-- | Objects/descrobject.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 9671102..11c68d3 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -766,6 +766,12 @@ proxy_str(proxyobject *pp) return PyObject_Str(pp->dict); } +static PyObject * +proxy_repr(proxyobject *pp) +{ + return PyUnicode_FromFormat("dict_proxy(%R)", pp->dict); +} + static int proxy_traverse(PyObject *self, visitproc visit, void *arg) { @@ -791,7 +797,7 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ - 0, /* tp_repr */ + (reprfunc)proxy_repr, /* tp_repr */ 0, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ &proxy_as_mapping, /* tp_as_mapping */ |