comparison cutils/util/crc32.py @ 259:b24080e5ca96

FIX: Handle OverflowErrlr when comparing CRCs with ints
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 16 Feb 2025 09:46:41 +0100
parents 57057028f13e
children 48430941c18c
comparison
equal deleted inserted replaced
258:57057028f13e 259:b24080e5ca96
52 52
53 def __eq__(self, other): 53 def __eq__(self, other):
54 if isinstance(other, crc32): 54 if isinstance(other, crc32):
55 return self._crc == other._crc 55 return self._crc == other._crc
56 elif isinstance(other, INT_TYPES): 56 elif isinstance(other, INT_TYPES):
57 return self._get_crc_as_uint32() == self.as_uint32(other) 57 try:
58 return self._get_crc_as_uint32() == self.as_uint32(other)
59 except OverflowError:
60 return False
58 else: 61 else:
59 return NotImplemented 62 return NotImplemented
60 63
61 def __ne__(self, other): 64 def __ne__(self, other):
62 equal = self.__eq__(other) 65 equal = self.__eq__(other)