[XS] Change in ...pyosmocom[master]: osmocom.utils: Make 'hexstr' type hashable
laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38204?usp=email ) Change subject: osmocom.utils: Make 'hexstr' type hashable ...................................................................... osmocom.utils: Make 'hexstr' type hashable otherwise we couldn't use hexstr values as dict keys, for example Change-Id: Ic9e1f8af1db436af5456fe5964133a144c9e066b --- M src/osmocom/utils.py 1 file changed, 4 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py index a218e1b..009eb04 100644 --- a/src/osmocom/utils.py +++ b/src/osmocom/utils.py @@ -41,6 +41,10 @@ # make sure comparison is done case-insensitive return str(self) == other.lower() + def __hash__(self): + # having a custom __eq__ method will make the type unhashable by default, lets fix that + return hash(str(self)) + def __getitem__(self, val) -> 'hexstr': # make sure slicing a hexstr will return a hexstr return hexstr(super().__getitem__(val)) -- To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38204?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: python/pyosmocom Gerrit-Branch: master Gerrit-Change-Id: Ic9e1f8af1db436af5456fe5964133a144c9e066b Gerrit-Change-Number: 38204 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org>
participants (1)
-
laforge