From b418f87f90671eed7158d7f7707c1a6c74b7c5ec Mon Sep 17 00:00:00 2001 From: kshithijiyer Date: Mon, 7 Sep 2020 17:47:15 +0530 Subject: [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 --- glustolibs-gluster/scripts/compute_hash.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'glustolibs-gluster/scripts') 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) -- cgit