Ignore:
Timestamp:
04/27/19 12:06:32 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Fixed ordering for classes that used cmp (re #347).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/logger.py

    r919 r921  
    77import time
    88import bisect
     9from functools import total_ordering
    910
    1011#--------------------------------------------------------------------------------------
     
    3435    increasing IDs."""
    3536
     37    @total_ordering
    3638    class Entry(object):
    3739        """An entry in the log."""
     
    119121                                id = self._id)
    120122
    121         def __cmp__(self, other):
    122             """Compare two entries
    123 
    124             First their timestamps are compared, and if those are equal, then
    125             their IDs."""
    126             result = cmp(self._timestamp, other.timestamp)
    127             if result==0:
    128                 result = cmp(self._id, other._id)
    129             return result
     123        def __eq__(self, other):
     124            """Equality comparison"""
     125            return self._timestamp == other.timestamp and \
     126                self._id == other._id
     127
     128        def __ne__(self, other):
     129            """Non-equality comparison"""
     130            return self._timestamp != other.timestamp or \
     131                self._id != other._id
     132
     133        def __lt__(self, other):
     134            """Less-than comparison"""
     135            return self._timestamp < other.timestamp or \
     136                (self._timestamp == other.timestamp and
     137                 self._id < other._id)
    130138
    131139    class Fault(object):
Note: See TracChangeset for help on using the changeset viewer.