[Python-checkins] CVS: python/dist/src/Objects weakrefobject.c,1.7,1.8
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 19 Dec 2001 08:44:32 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv8472/Objects
Modified Files:
weakrefobject.c
Log Message:
proxy_compare(): Make sure that we unwrap both objects being compared if
both are proxy objects.
Index: weakrefobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** weakrefobject.c 2001/12/10 23:44:54 1.7
--- weakrefobject.c 2001/12/19 16:44:30 1.8
***************
*** 221,224 ****
--- 221,231 ----
}
+ #define UNWRAP_I(o) \
+ if (PyWeakref_CheckProxy(o)) { \
+ if (!proxy_checkref((PyWeakReference *)o)) \
+ return -1; \
+ o = PyWeakref_GET_OBJECT(o); \
+ }
+
#define WRAP_UNARY(method, generic) \
static PyObject * \
***************
*** 285,293 ****
static int
! proxy_compare(PyWeakReference *proxy, PyObject *v)
{
! if (!proxy_checkref(proxy))
! return -1;
! return PyObject_Compare(PyWeakref_GET_OBJECT(proxy), v);
}
--- 292,300 ----
static int
! proxy_compare(PyObject *proxy, PyObject *v)
{
! UNWRAP_I(proxy);
! UNWRAP_I(v);
! return PyObject_Compare(proxy, v);
}
***************
*** 452,456 ****
0, /*tp_getattr*/
0, /*tp_setattr*/
! (cmpfunc)proxy_compare, /*tp_compare*/
(unaryfunc)proxy_repr, /*tp_repr*/
&proxy_as_number, /*tp_as_number*/
--- 459,463 ----
0, /*tp_getattr*/
0, /*tp_setattr*/
! proxy_compare, /*tp_compare*/
(unaryfunc)proxy_repr, /*tp_repr*/
&proxy_as_number, /*tp_as_number*/
***************
*** 483,487 ****
0, /*tp_getattr*/
0, /*tp_setattr*/
! (cmpfunc)proxy_compare, /*tp_compare*/
(unaryfunc)proxy_repr, /*tp_repr*/
&proxy_as_number, /*tp_as_number*/
--- 490,494 ----
0, /*tp_getattr*/
0, /*tp_setattr*/
! proxy_compare, /*tp_compare*/
(unaryfunc)proxy_repr, /*tp_repr*/
&proxy_as_number, /*tp_as_number*/