[Ironpython-users] Why does this happen?

Slide slide.o.mix at gmail.com
Sun Mar 25 05:51:42 CEST 2012


I am implementing a module in C#. This module does some comparison
operations. One of the tests for this module has something like the
following:

class CmpErr:
    def __cmp__(self, other):
        raise ZeroDivisionError

x = [CmpErr(), CmpErr(), CmpErr()]
cSharpMethod(x)

Inside cSharpMethod is when I do the comparison. The way I am doing the
comparison is taken from how its done in List.cs

IComparer comparer =
PythonContext.GetContext(context).GetComparer(null,
GetComparisonType(context, list));

Then I call comparer.Compare on the two items. In List.sort, this
eventually calls the __cmp__ method if I try adding a call to x.sort()
instead of cSharpMethod, but from inside cSharpMethod, __cmp__ is never
called and I can't figure out why.

Any ideas on why this might be occuring?

Thanks,

slide

-- 
Website: http://earl-of-code.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120324/ffedc9f2/attachment.html>


More information about the Ironpython-users mailing list