summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-09-07 17:47:15 +0530
committerArthy Loganathan <aloganat@redhat.com>2020-09-08 02:41:24 +0000
commitb418f87f90671eed7158d7f7707c1a6c74b7c5ec (patch)
tree960298f505a719d44cc61425baf00429f66539ac /glustolibs-gluster
parent7dfc0b1bb5018785f10b25224f10e92fa943e6f8 (diff)
[Libfix] Fix python3 break in c_unit32()
Problem: In python3, c_unit32() needs explict declaration of encoding due to which the hash calculated by compute_hash.py was wrong causeing 8 failures in latest CI runs on the newer platforms like CentOS 8. Solution: Add logic to specifiy encoding based on the version of python. Change-Id: I8907d8d266ac20d29d730a5ed948cf4da30f01b8 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r--glustolibs-gluster/scripts/compute_hash.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/glustolibs-gluster/scripts/compute_hash.py b/glustolibs-gluster/scripts/compute_hash.py
index b5ae2f83b..7cab7c494 100644
--- a/glustolibs-gluster/scripts/compute_hash.py
+++ b/glustolibs-gluster/scripts/compute_hash.py
@@ -20,7 +20,13 @@ import sys
filename = sys.argv[1]
glusterfs = ctypes.cdll.LoadLibrary("libglusterfs.so.0")
-computed_hash = ctypes.c_uint32(glusterfs.gf_dm_hashfn(filename,
- len(filename)))
+
+# In case of python3 encode string to ascii
+if sys.version_info.major == 3:
+ computed_hash = ctypes.c_uint32(glusterfs.gf_dm_hashfn(
+ filename.encode('ascii'), len(filename)))
+else:
+ computed_hash = ctypes.c_uint32(glusterfs.gf_dm_hashfn(
+ filename, len(filename)))
print(computed_hash.value)