changeset 207:0e8c12ff0f41

FIX: For Python2.7 correct the CRC only if is < 0
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 22 Jan 2025 18:57:44 +0100
parents 73d22943da5a
children 85e7edea8ac7
files cutils/treesum.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Wed Jan 22 17:55:49 2025 +0100
+++ b/cutils/treesum.py	Wed Jan 22 18:57:44 2025 +0100
@@ -761,8 +761,11 @@
 
         """
         if util.PY2:
-            # Return the bitpattern as unsigned 32-bit number
-            return (~self._crc32 ^ 0xFFFFFFFF)
+            if self._crc32 < 0:
+                # Return the bitpattern as unsigned 32-bit number
+                return (~self._crc32 ^ 0xFFFFFFFF)
+            else:
+                return self._crc32
         else:
             return self._crc32
 
@@ -1011,8 +1014,11 @@
 
         """
         if util.PY2:
-            # Return the bitpattern as unsigned 32-bit number
-            return (~self._crc32 ^ 0xFFFFFFFF)
+            if self._crc32 < 0:
+                # Return the bitpattern as unsigned 32-bit number
+                return (~self._crc32 ^ 0xFFFFFFFF)
+            else:
+                return self._crc32
         else:
             return self._crc32