fix fingerprint comparisons

This commit is contained in:
Michael Greene
2022-11-23 10:48:56 -08:00
parent 937f36bd62
commit 7d228ab7ee

View File

@@ -8,6 +8,7 @@ import binascii
import bisect import bisect
import codecs import codecs
import collections import collections
import itertools
import operator import operator
import os import os
import re import re
@@ -30,7 +31,6 @@ __all__ = ['Armorable',
'MetaDispatchable', 'MetaDispatchable',
'Dispatchable', 'Dispatchable',
'SignatureVerification', 'SignatureVerification',
'FlagEnum',
'Fingerprint', 'Fingerprint',
'SorteDeque'] 'SorteDeque']
@@ -659,15 +659,15 @@ class Fingerprint(str):
if isinstance(other, (bytes, bytearray)): # pragma: no cover if isinstance(other, (bytes, bytearray)): # pragma: no cover
other = other.decode('latin-1') other = other.decode('latin-1')
other = str(other).replace(' ', '') other = other.replace(' ', '')
return any([self.replace(' ', '') == other, return any([str(self) == other,
self.keyid == other, self.keyid == other,
self.shortid == other]) self.shortid == other])
return False # pragma: no cover return False # pragma: no cover
def __ne__(self, other): def __ne__(self, other):
return str(self) != str(other) return not (self == str(other))
def __hash__(self): def __hash__(self):
return hash(str(self)) return hash(str(self))