From b67f98d1e982b37ab80c32c019c5c221512e608e Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 16 Mar 2020 21:38:29 -0400 Subject: add __lt__ to referencesource objects and raise exception if invalid type --- python/architecture.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python/architecture.py') diff --git a/python/architecture.py b/python/architecture.py index b9001bf3..a6e1a083 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -2724,6 +2724,16 @@ class ReferenceSource(object): else: return "" % self._address + def __eq__(self, value): + if not isinstance(value, ReferenceSource): + return False + return self.function == value.function and self.arch == value.arch and self.address == value.address + + def __lt__(self, value): + if not isinstance(value, ReferenceSource): + raise TypeError("Can only compare to other ReferenceSource objects") + return self.address < value.address + @property def function(self): """ """ -- cgit v1.3.1