Index: Objects/descrobject.c =================================================================== --- Objects/descrobject.c (revision 87109) +++ Objects/descrobject.c (working copy) @@ -766,6 +766,12 @@ 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 @@ 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 */ Index: Lib/test/test_descr.py =================================================================== --- Lib/test/test_descr.py (revision 87109) +++ Lib/test/test_descr.py (working copy) @@ -4268,7 +4268,12 @@ pass self.assertEqual(type(C.__dict__), type(B.__dict__)) + def test_repr(self): + # Testing dict_proxy.__repr__ + dict_ = {k: v for k, v in self.C.__dict__.items()} + self.assertEqual(repr(self.C.__dict__), 'dict_proxy({!r})'.format(dict_)) + class PTypesLongInitTest(unittest.TestCase): # This is in its own TestCase so that it can be run before any other tests. def test_pytype_long_ready(self):