[Python-checkins] r87370 - in python/branches/release31-maint: Lib/test/test_descr.py Misc/NEWS Objects/descrobject.c
ezio.melotti
python-checkins at python.org
Sat Dec 18 16:06:45 CET 2010
Author: ezio.melotti
Date: Sat Dec 18 16:06:45 2010
New Revision: 87370
Log:
Merged revisions 87368 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87368 | ezio.melotti | 2010-12-18 15:59:43 +0100 (Sat, 18 Dec 2010) | 1 line
#5587: add a repr to dict_proxy objects. Patch by David Stanek and Daniel Urban.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_descr.py
python/branches/release31-maint/Misc/NEWS
python/branches/release31-maint/Objects/descrobject.c
Modified: python/branches/release31-maint/Lib/test/test_descr.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_descr.py (original)
+++ python/branches/release31-maint/Lib/test/test_descr.py Sat Dec 18 16:06:45 2010
@@ -4262,6 +4262,11 @@
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.
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Sat Dec 18 16:06:45 2010
@@ -18,6 +18,9 @@
float.__divmod__ with respect to signed zeros. -4.0 % 4.0 should be
0.0, not -0.0.
+- Issue #5587: add a repr to dict_proxy objects. Patch by David Stanek and
+ Daniel Urban.
+
Library
-------
Modified: python/branches/release31-maint/Objects/descrobject.c
==============================================================================
--- python/branches/release31-maint/Objects/descrobject.c (original)
+++ python/branches/release31-maint/Objects/descrobject.c Sat Dec 18 16:06:45 2010
@@ -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 */
More information about the Python-checkins
mailing list