From d0ae77c324d2e7cd2108e2c652c6dde9302496c4 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 8 May 2018 14:17:36 -0400 Subject: [PATCH] py3: Unicode strings must be encoded to bytes before hashing. --- module_build_service/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module_build_service/models.py b/module_build_service/models.py index 748178e1..4842ad58 100644 --- a/module_build_service/models.py +++ b/module_build_service/models.py @@ -376,13 +376,13 @@ class ModuleBuild(MBSBase): mmd_formatted_buildrequires = { dep: info['ref'] for dep, info in mbs_xmd["buildrequires"].items()} property_json = json.dumps(OrderedDict(sorted(mmd_formatted_buildrequires.items()))) - rv.append(hashlib.sha1(property_json).hexdigest()) + rv.append(hashlib.sha1(property_json.encode('utf-8')).hexdigest()) # Get the streams of buildrequires and hash it. mmd_formatted_buildrequires = { dep: info['stream'] for dep, info in mbs_xmd["buildrequires"].items()} property_json = json.dumps(OrderedDict(sorted(mmd_formatted_buildrequires.items()))) - build_context = hashlib.sha1(property_json).hexdigest() + build_context = hashlib.sha1(property_json.encode('utf-8')).hexdigest() rv.append(build_context) # Get the requires from the real "dependencies" section in MMD. @@ -400,8 +400,8 @@ class ModuleBuild(MBSBase): runtime_context = hashlib.sha1(property_json.encode('utf-8')).hexdigest() rv.append(runtime_context) - combined_hashes = '{0}:{1}'.format(build_context, runtime_context).encode('utf-8') - context = hashlib.sha1(combined_hashes).hexdigest()[:8] + combined_hashes = '{0}:{1}'.format(build_context, runtime_context) + context = hashlib.sha1(combined_hashes.encode('utf-8')).hexdigest()[:8] rv.append(context) return tuple(rv)