changeset 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 0f4febf646f5
children c1e875ba4bdc
files cutils/treesum.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Thu Jan 16 20:01:37 2025 +0100
+++ b/cutils/treesum.py	Thu Jan 16 20:40:24 2025 +0100
@@ -590,7 +590,7 @@
         :rtype: str
 
         """
-        return (hex(self._crc32)[2:]).upper()
+        return (hex(self.crcdigest())[2:]).upper()
 
     def crcdigest(self):
         """
@@ -598,7 +598,11 @@
         :rtype: int
 
         """
-        return self._crc32
+        if util.PY2:
+            # Return the bitpattern as unsigned 32-bit number
+            return (~self._crc32 ^ 0xFFFFFFFF)
+        else:
+            return self._crc32
 
 
 def normalized_compatible_mode_str(mode):