mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
#5587: add a repr to dict_proxy objects. Patch by David Stanek and Daniel Urban.
This commit is contained in:
parent
197c9c945e
commit
ac53ab64a6
3 changed files with 15 additions and 1 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue