[ZODB-Dev] ExtensionClass tp_compare fix

Neil Schemenauer nas at mems-exchange.org
Wed Jul 30 18:46:21 EDT 2003


The attached patch to ExtensionClass.c is necessary to prevent a
RuntimeWarning from Python 2.3 when comparing to ExtensionClass
instances.

  Neil


--- ExtensionClass.c~	2003-07-30 17:36:05.000000000 -0400
+++ ExtensionClass.c	2003-07-30 17:41:24.000000000 -0400
@@ -2298,8 +2298,10 @@
 
   UNLESS(m=subclass_getspecial(self,py__cmp__))
     {
+      Py_uintptr_t iself = (Py_uintptr_t)self;
+      Py_uintptr_t iv = (Py_uintptr_t)v;
       PyErr_Clear();
-      return self-v;
+      return (iself < iv) ? -1 : (iself > iv) ? 1 : 0;
     }
 
   if (UnboundCMethod_Check(m)



More information about the ZODB-Dev mailing list