| Update of /cvsroot/pywin32/pywin32/com/win32com/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21528/com/win32com/src
Modified Files:
	MiscTypes.cpp PyIBase.cpp 
Log Message:
Remove __cmp__ and tp_compare slots from COM objects and return 
Py_NotImplemented in richcmp functions when faced with different types.
Index: MiscTypes.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/MiscTypes.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** MiscTypes.cpp	19 Dec 2008 02:28:48 -0000	1.11
--- MiscTypes.cpp	4 Feb 2009 04:01:25 -0000	1.12
***************
*** 49,58 ****
  		0, 													/*tp_getattr*/
  		0,													/*tp_setattr*/
! // For b/w compat, we still allow 'cmp()' to work with Py2k, but for Py3k only rich compare is supported.
! #if (PY_VERSION_HEX < 0x03000000)
! 		PyIBase::cmp,										/*tp_compare*/
! #else
! 		0,
! #endif
  		(reprfunc)PyIBase::repr,							/*tp_repr*/
      	0,													/*tp_as_number*/
--- 49,53 ----
  		0, 													/*tp_getattr*/
  		0,													/*tp_setattr*/
! 		0,										/*tp_compare*/
  		(reprfunc)PyIBase::repr,							/*tp_repr*/
      	0,													/*tp_as_number*/
Index: PyIBase.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIBase.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PyIBase.cpp	19 Dec 2008 02:28:48 -0000	1.9
--- PyIBase.cpp	4 Feb 2009 04:01:25 -0000	1.10
***************
*** 79,84 ****
  	int c = cmp(ob1, ob2);
  	// BUT - it doesn't propogate exceptions correctly.
! 	if (c==-1 && PyErr_Occurred())
  		return NULL;
  	assert(!PyErr_Occurred()); // should always have returned -1 on error.
  	BOOL ret;
--- 79,92 ----
  	int c = cmp(ob1, ob2);
  	// BUT - it doesn't propogate exceptions correctly.
! 	if (c==-1 && PyErr_Occurred()) {
! 		// if the error related to the type of the object,
! 		// rich-compare wants Py_NotImplemented returned.
! 		if (PyErr_ExceptionMatches(PyExc_TypeError)) {
! 			PyErr_Clear();
! 			Py_INCREF(Py_NotImplemented);
! 			return Py_NotImplemented;
! 		}
  		return NULL;
+ 	}
  	assert(!PyErr_Occurred()); // should always have returned -1 on error.
  	BOOL ret;
***************
*** 88,93 ****
  		ret = c != 0;
  	else {
! 		PyErr_SetString(PyExc_TypeError, "Interface pointers only compare equal or not equal");
! 		return NULL;
  	}
  	return PyBool_FromLong(ret);
--- 96,101 ----
  		ret = c != 0;
  	else {
! 		Py_INCREF(Py_NotImplemented);
! 		return Py_NotImplemented;
  	}
  	return PyBool_FromLong(ret);
 |