pass
self.C = C
+ def test_repr(self):
+ self.assertIn('dict_proxy({', repr(vars(self.C)))
+ self.assertIn("'meth':", repr(vars(self.C)))
+
def test_iter_keys(self):
# Testing dict-proxy iterkeys...
keys = [ key for key in self.C.__dict__.iterkeys() ]
the following case: sys.stdin.read() stopped with CTRL+d (end of file),
raw_input() interrupted by CTRL+c.
+- dict_proxy objects now display their contents rather than just the class name.
+
Library
-------
return PyObject_Str(pp->dict);
}
+static PyObject *
+proxy_repr(proxyobject *pp)
+{
+ PyObject *dictrepr;
+ PyObject *result;
+
+ dictrepr = PyObject_Repr(pp->dict);
+ if (dictrepr == NULL)
+ return NULL;
+ result = PyString_FromFormat("dict_proxy(%s)", PyString_AS_STRING(dictrepr));
+ Py_DECREF(dictrepr);
+ return result;
+}
+
static int
proxy_traverse(PyObject *self, visitproc visit, void *arg)
{
0, /* tp_getattr */
0, /* tp_setattr */
(cmpfunc)proxy_compare, /* tp_compare */
- 0, /* tp_repr */
+ (reprfunc)proxy_repr, /* tp_repr */
0, /* tp_as_number */
&proxy_as_sequence, /* tp_as_sequence */
&proxy_as_mapping, /* tp_as_mapping */