Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22484/win32/src
Modified Files:
PyHANDLE.cpp PyIID.cpp PyWinObjects.h
Log Message:
Remove __cmp__ and tp_compare slots for PyHANDLE and PyIID objects and
return Py_NotImplemented in richcmp functions when faced with different
types.
Index: PyWinObjects.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** PyWinObjects.h 19 Dec 2008 05:24:35 -0000 1.19
--- PyWinObjects.h 4 Feb 2009 04:07:54 -0000 1.20
***************
*** 18,22 ****
/* Python support */
- int compare(PyObject *ob);
PyObject *richcompare(PyObject *other, int op);
long hash(void);
--- 18,21 ----
***************
*** 26,30 ****
static void deallocFunc(PyObject *ob);
static int printFunc(PyObject *ob, FILE *fp, int flags);
- static int compareFunc(PyObject *ob1, PyObject *ob2);
static PyObject *richcompareFunc(PyObject *self, PyObject *other, int op);
static long hashFunc(PyObject *ob);
--- 25,28 ----
***************
*** 139,143 ****
/* Python support */
- int compare(PyObject *ob);
PyObject *richcompare(PyObject *other, int op);
--- 137,140 ----
***************
*** 148,152 ****
static void deallocFunc(PyObject *ob);
static int printFunc(PyObject *ob, FILE *fp, int flags);
- static int compareFunc(PyObject *ob1, PyObject *ob2);
static PyObject *richcompareFunc(PyObject *ob, PyObject *other, int op);
static int nonzeroFunc(PyObject *ob);
--- 145,148 ----
Index: PyIID.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyIID.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** PyIID.cpp 11 Dec 2008 00:25:40 -0000 1.11
--- PyIID.cpp 4 Feb 2009 04:07:54 -0000 1.12
***************
*** 170,175 ****
0, /* tp_getattr */
0, /* tp_setattr */
! // @pymeth __cmp__|Used when IID objects are compared.
! PyIID::compareFunc, /* tp_compare */
// @pymeth __repr__|Used whenever a repr() is called for the object
PyIID::reprFunc, /* tp_repr */
--- 170,174 ----
0, /* tp_getattr */
0, /* tp_setattr */
! 0, /* tp_compare */
// @pymeth __repr__|Used whenever a repr() is called for the object
PyIID::reprFunc, /* tp_repr */
***************
*** 231,270 ****
}
- int PyIID::compare(PyObject *ob)
- {
- return memcmp(&m_iid, &((PyIID *)ob)->m_iid, sizeof(m_iid));
- }
-
// Py3k requires that objects implement richcompare to be used as dict keys
PyObject *PyIID::richcompare(PyObject *other, int op)
{
! BOOL e;
! if (PyIID_Check(other))
! e=IsEqualIID(m_iid, ((PyIID *)other)->m_iid);
! else
! e=FALSE;
!
if (op==Py_EQ){
! if (e){
! Py_INCREF(Py_True);
! return Py_True;
! }
! else{
! Py_INCREF(Py_False);
! return Py_False;
! }
! }
! if (op==Py_NE){
! if (!e){
! Py_INCREF(Py_True);
! return Py_True;
! }
! else{
! Py_INCREF(Py_False);
! return Py_False;
! }
! }
! PyErr_SetString(PyExc_TypeError, "IIDs only compare equal or not equal");
! return NULL;
}
--- 230,251 ----
}
// Py3k requires that objects implement richcompare to be used as dict keys
PyObject *PyIID::richcompare(PyObject *other, int op)
{
! if (!PyIID_Check(other)) {
! Py_INCREF(Py_NotImplemented);
! return Py_NotImplemented;
! }
! BOOL e = IsEqualIID(m_iid, ((PyIID *)other)->m_iid);
! PyObject *ret;
if (op==Py_EQ){
! ret = e ? Py_True : Py_False;
! }
! else if (op==Py_NE) {
! ret = e ? Py_False : Py_True;
! } else
! ret = Py_NotImplemented;
! Py_INCREF(ret);
! return ret;
}
***************
*** 299,308 ****
}
- // @pymethod int|PyIID|__cmp__|Used when IID objects are compared.
- int PyIID::compareFunc(PyObject *ob1, PyObject *ob2)
- {
- return ((PyIID *)ob1)->compare(ob2);
- }
-
// Py3k requires that objects implement richcompare to be used as dict keys
PyObject *PyIID::richcompareFunc(PyObject *self, PyObject *other, int op)
--- 280,283 ----
Index: PyHANDLE.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** PyHANDLE.cpp 17 Dec 2008 13:12:56 -0000 1.20
--- PyHANDLE.cpp 4 Feb 2009 04:07:54 -0000 1.21
***************
*** 166,171 ****
0, /* tp_getattr */
0, /* tp_setattr */
! // @pymeth __cmp__|Used when HANDLE objects are compared.
! PyHANDLE::compareFunc, /* tp_compare */
PyHANDLE::strFunc, /* tp_repr */
&PyHANDLE_NumberMethods, /* tp_as_number */
--- 166,170 ----
0, /* tp_getattr */
0, /* tp_setattr */
! 0, /* tp_compare */
PyHANDLE::strFunc, /* tp_repr */
&PyHANDLE_NumberMethods, /* tp_as_number */
***************
*** 267,284 ****
}
- int PyHANDLE::compare(PyObject *ob)
- {
-
- return m_handle == ((PyHANDLE *)ob)->m_handle ? 0 :
- (m_handle < ((PyHANDLE *)ob)->m_handle ? -1 : 1);
- }
-
PyObject *PyHANDLE::richcompare(PyObject *other, int op)
{
! BOOL e;
! if (PyHANDLE_Check(other))
! e=compare((PyHANDLE *)other)==0;
! else
! e=FALSE;
PyObject *ret;
if (op==Py_EQ)
--- 266,277 ----
}
PyObject *PyHANDLE::richcompare(PyObject *other, int op)
{
! if (!PyHANDLE_Check(other)) {
! Py_INCREF(Py_NotImplemented);
! return Py_NotImplemented;
! }
!
! BOOL e = m_handle == ((PyHANDLE *)other)->m_handle;
PyObject *ret;
if (op==Py_EQ)
***************
*** 286,294 ****
else if (op==Py_NE)
ret = !e ? Py_True : Py_False;
! else {
! PyErr_SetString(PyExc_TypeError, "HANDLEs only compare equal or not equal");
! ret = NULL;
! }
! Py_XINCREF(ret);
return ret;
}
--- 279,285 ----
else if (op==Py_NE)
ret = !e ? Py_True : Py_False;
! else
! ret = Py_NotImplemented;
! Py_INCREF(ret);
return ret;
}
***************
*** 321,330 ****
- // @pymethod int|PyHANDLE|__cmp__|Used when objects are compared.
- int PyHANDLE::compareFunc(PyObject *ob1, PyObject *ob2)
- {
- return ((PyHANDLE *)ob1)->compare(ob2);
- }
-
PyObject *PyHANDLE::richcompareFunc(PyObject *ob, PyObject *other, int op)
{
--- 312,315 ----
|