summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-08-31 15:51:04 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-08-31 15:51:04 (GMT)
commit29a6d449ef8ea42009215318f8d43a569aed2cf7 (patch)
treedadb6652eaea918bad4166ba204790a478542836 /Objects/descrobject.c
parentf689492070e9640a6d9e0e4629f78d5748b9437e (diff)
downloadcpython-29a6d449ef8ea42009215318f8d43a569aed2cf7.zip
cpython-29a6d449ef8ea42009215318f8d43a569aed2cf7.tar.gz
cpython-29a6d449ef8ea42009215318f8d43a569aed2cf7.tar.bz2
Added comparison functions to dict proxies.
Now all non-mutating dict methods are in the proxy also. Inspired by SF bug #602232,
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index fc9d9a1..63e94e8 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -718,6 +718,18 @@ proxy_traverse(PyObject *self, visitproc visit, void *arg)
return 0;
}
+static int
+proxy_compare(proxyobject *v, PyObject *w)
+{
+ return PyObject_Compare(v->dict, w);
+}
+
+static PyObject *
+proxy_richcompare(proxyobject *v, PyObject *w, int op)
+{
+ return PyObject_RichCompare(v->dict, w, op);
+}
+
static PyTypeObject proxytype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
@@ -729,7 +741,7 @@ static PyTypeObject proxytype = {
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_compare */
+ (cmpfunc)proxy_compare, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
&proxy_as_sequence, /* tp_as_sequence */
@@ -744,7 +756,7 @@ static PyTypeObject proxytype = {
0, /* tp_doc */
proxy_traverse, /* tp_traverse */
0, /* tp_clear */
- 0, /* tp_richcompare */
+ (richcmpfunc)proxy_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)proxy_getiter, /* tp_iter */
0, /* tp_iternext */