Skip to content
Snippets Groups Projects
Commit 066b1d5d authored by Pierre LALET's avatar Pierre LALET
Browse files

Make FlagValue objects hashable

This will make them usable as set elements or dict or Counter keys.
parent 1944f788
No related branches found
No related tags found
No related merge requests found
...@@ -1039,6 +1039,8 @@ class FlagValue(object): ...@@ -1039,6 +1039,8 @@ class FlagValue(object):
self.multi = isinstance(names, list) self.multi = isinstance(names, list)
self.names = names self.names = names
self.value = self._fixvalue(value) self.value = self._fixvalue(value)
def __hash__(self):
return hash(self.value)
def __int__(self): def __int__(self):
return self.value return self.value
def __eq__(self, other): def __eq__(self, other):
......
...@@ -8185,6 +8185,8 @@ assert pkt.flags.DF ...@@ -8185,6 +8185,8 @@ assert pkt.flags.DF
assert pkt.flags.evil assert pkt.flags.evil
assert repr(pkt.flags) == '<Flag 6 (DF+evil)>' assert repr(pkt.flags) == '<Flag 6 (DF+evil)>'
assert len({IP().flags, IP().flags}) == 1
= TCP flags = TCP flags
~ TCP ~ TCP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment