diff options
author | Mathieu Bridon <[email protected]> | 2018-07-17 22:57:39 +0200 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-08-07 13:10:34 -0700 |
commit | e1b88aee680bbdadd283b4a26db74672bb130df5 (patch) | |
tree | aa7b7026af801eae5202200e5ad10e861a543145 /src/mapi/mapi_abi.py | |
parent | 9b6746b7c0bef64be419c8cf2ecd916980e2718a (diff) |
python: Fix rich comparisons
Python 3 doesn't call objects __cmp__() methods any more to compare
them. Instead, it requires implementing the rich comparison methods
explicitly: __eq__(), __ne(), __lt__(), __le__(), __gt__() and __ge__().
Fortunately Python 2 also supports those.
This commit only implements the comparison methods which are actually
used by the build scripts.
Signed-off-by: Mathieu Bridon <[email protected]>
Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/mapi/mapi_abi.py')
-rw-r--r-- | src/mapi/mapi_abi.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py index be1d15d9224..e4ce2b6cafd 100644 --- a/src/mapi/mapi_abi.py +++ b/src/mapi/mapi_abi.py @@ -121,19 +121,18 @@ class ABIEntry(object): def __str__(self): return self.c_prototype() - def __cmp__(self, other): + def __lt__(self, other): # compare slot, alias, and then name - res = cmp(self.slot, other.slot) - if not res: + if self.slot == other.slot: if not self.alias: - res = -1 + return True elif not other.alias: - res = 1 + return False - if not res: - res = cmp(self.name, other.name) + return self.name < other.name + + return self.slot < other.slot - return res def abi_parse_xml(xml): """Parse a GLAPI XML file for ABI entries.""" |