Skip to content

Commit

Permalink
PYCBC-243: iops/select: Use rich comparison methods rather than __cmp__
Browse files Browse the repository at this point in the history
This fixes an issue where tests would fail under Python 3. The __cmp__
method is not used in Python 3, which rather expects to find the rich
comparison operations
(https://docs.python.org/2/reference/datamodel.html#object.__lt__)

Change-Id: I4c0cdb3d7bd96bbefdec58e65ddc2b382acca458
Reviewed-on: http://review.couchbase.org/37083
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
  • Loading branch information
mnunberg committed May 20, 2014
1 parent bdf2455 commit 3764317
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions couchbase/iops/select.py
Expand Up @@ -51,9 +51,13 @@ def deactivate(self):
def active(self):
return self.state == PYCBC_EVSTATE_ACTIVE

def __cmp__(self, other):
return cmp(self.exptime, other.exptime)

# Rich comparison operators implemented - __cmp__ not used in Py3
def __lt__(self, other): return self.exptime < other.exptime
def __le__(self, other): return self.exptime <= other.exptime
def __gt__(self, other): return self.exptime > other.exptime
def __ge__(self, other): return self.exptime >= other.exptime
def __ne__(self, other): return self.exptime != other.exptime
def __eq__(self, other): return self.exptime == other.exptime


class SelectIOPS(object):
Expand Down

0 comments on commit 3764317

Please sign in to comment.