mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-03 03:36:44 +00:00
Fix comparison of NummedObj against non-NummedObj
Previously this would explode with AttributeError.
This commit is contained in:
parent
fc62fd31a0
commit
6ca328ba94
@ -1,7 +1,9 @@
|
||||
import collections, itertools
|
||||
import collections, itertools, functools
|
||||
|
||||
objnums = collections.defaultdict(itertools.count)
|
||||
|
||||
|
||||
@functools.total_ordering
|
||||
class NummedObj(object):
|
||||
"""
|
||||
This is useful for nicer debug printouts. Instead of objects of the same class being
|
||||
@ -27,22 +29,14 @@ class NummedObj(object):
|
||||
return "<%s #%d>" % (self._classname, self._objid,)
|
||||
|
||||
def __lt__(self, other):
|
||||
return (self._objid, self._classname,) < (other._objid, other._classname,)
|
||||
|
||||
def __le__(self, other):
|
||||
return (self._objid, self._classname,) <= (other._objid, other._classname,)
|
||||
if isinstance(other, NummedObj):
|
||||
return (self._objid, self._classname,) < (other._objid, other._classname,)
|
||||
return NotImplemented
|
||||
|
||||
def __eq__(self, other):
|
||||
return (self._objid, self._classname,) == (other._objid, other._classname,)
|
||||
|
||||
def __ne__(self, other):
|
||||
return (self._objid, self._classname,) != (other._objid, other._classname,)
|
||||
|
||||
def __gt__(self, other):
|
||||
return (self._objid, self._classname,) > (other._objid, other._classname,)
|
||||
|
||||
def __ge__(self, other):
|
||||
return (self._objid, self._classname,) >= (other._objid, other._classname,)
|
||||
if isinstance(other, NummedObj):
|
||||
return (self._objid, self._classname,) == (other._objid, other._classname,)
|
||||
return NotImplemented
|
||||
|
||||
def __hash__(self):
|
||||
return id(self)
|
||||
|
Loading…
Reference in New Issue
Block a user