logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

r30537 - lxml/branch/capi/src/lxml: msg#00101

Subject: r30537 - lxml/branch/capi/src/lxml
Author: scoder
Date: Tue Jul 25 19:44:48 2006
New Revision: 30537

Modified:
   lxml/branch/capi/src/lxml/objectify.pyx
   lxml/branch/capi/src/lxml/python.pxd
Log:
fixed rich compare implementations

Modified: lxml/branch/capi/src/lxml/objectify.pyx
==============================================================================
--- lxml/branch/capi/src/lxml/objectify.pyx     (original)
+++ lxml/branch/capi/src/lxml/objectify.pyx     Tue Jul 25 19:44:48 2006
@@ -337,16 +337,8 @@
 #    def __hex__(self):
 
     def __richcmp__(self, other, int op):
-        cdef int c
-        text  = _numericValueOf(self)
-        other = _numericValueOf(other)
-        c = _cmp(text, other)
-        if c < 0:
-            return op <= 1 or op == 3
-        elif c > 0:
-            return op >= 3
-        else:
-            return op == 2
+        return python.PyObject_RichCompareBool(
+            _numericValueOf(self), _numericValueOf(other), op)
 
     def __add__(self, other):
         return _numericValueOf(self) + _numericValueOf(other)
@@ -433,16 +425,8 @@
         return _len(_strValueOf(self))
 
     def __richcmp__(self, other, int op):
-        cdef int c
-        text  = _strValueOf(self)
-        other = _strValueOf(other)
-        c = _cmp(text, other)
-        if c < 0:
-            return op <= 1 or op == 3
-        elif c > 0:
-            return op >= 3
-        else:
-            return op == 2
+        return python.PyObject_RichCompareBool(
+            _strValueOf(self), _strValueOf(other), op)
 
     def __str__(self):
         return textOf(self._c_node)
@@ -538,6 +522,9 @@
             textOf((<NumberElement>obj)._c_node))
     return obj
 
+################################################################################
+# Python type registry
+
 cdef class PyType:
     """User defined type.
 

Modified: lxml/branch/capi/src/lxml/python.pxd
==============================================================================
--- lxml/branch/capi/src/lxml/python.pxd        (original)
+++ lxml/branch/capi/src/lxml/python.pxd        Tue Jul 25 19:44:48 2006
@@ -57,6 +57,7 @@
     cdef int PyType_Check(object instance)
 
     cdef int PyObject_SetAttr(object o, object name, object value)
+    cdef int PyObject_RichCompareBool(object o1, object o2, int op)
 
     cdef void* PyMem_Malloc(size_t size)
     cdef void* PyMem_Realloc(void* p, size_t size)


<Prev in Thread] Current Thread [Next in Thread>