1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Got rid of old __cmp__methods replaced by rich comparison.

The __cmp__ methods are unsupported in Python 3.
_doctest.py has been left untouched because it is likely it will
not be migrated to Python 3.
This commit is contained in:
Claude Paroz
2012-05-18 14:52:24 +02:00
parent 45f55a9fcc
commit d04f72fb31
5 changed files with 69 additions and 29 deletions

View File

@@ -155,12 +155,12 @@ class BoundMethodWeakref(object):
def __nonzero__( self ):
"""Whether we are still a valid reference"""
return self() is not None
def __cmp__( self, other ):
def __eq__(self, other):
"""Compare with another reference"""
if not isinstance (other,self.__class__):
return cmp( self.__class__, type(other) )
return cmp( self.key, other.key)
if not isinstance(other, self.__class__):
return self.__class__ == type(other)
return self.key == other.key
def __call__(self):
"""Return a strong reference to the bound method