comparison cutils/treesum.py @ 197:48e2610978e5

Return the CRC-32 digest on Python2 as unsigned int instead of a signed one. On Python3 it is always unsigned.
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 16 Jan 2025 20:40:24 +0100
parents fb36e71f6ba8
children c1e875ba4bdc
comparison
equal deleted inserted replaced
196:0f4febf646f5 197:48e2610978e5
588 """ 588 """
589 589
590 :rtype: str 590 :rtype: str
591 591
592 """ 592 """
593 return (hex(self._crc32)[2:]).upper() 593 return (hex(self.crcdigest())[2:]).upper()
594 594
595 def crcdigest(self): 595 def crcdigest(self):
596 """ 596 """
597 597
598 :rtype: int 598 :rtype: int
599 599
600 """ 600 """
601 return self._crc32 601 if util.PY2:
602 # Return the bitpattern as unsigned 32-bit number
603 return (~self._crc32 ^ 0xFFFFFFFF)
604 else:
605 return self._crc32
602 606
603 607
604 def normalized_compatible_mode_str(mode): 608 def normalized_compatible_mode_str(mode):
605 # XXX FIXME: Windows and "executable" 609 # XXX FIXME: Windows and "executable"
606 modebits = stat.S_IMODE(mode) 610 modebits = stat.S_IMODE(mode)