From 7c2d6a970d6af6785491e11eecd61d4bc37d4b13 Mon Sep 17 00:00:00 2001 From: yatin Date: Thu, 15 Nov 2018 17:31:17 +0530 Subject: [PATCH] Fix python3 Compatibility for hashlib md5 update Without this change in Python3 it returns following:- TypeError: Unicode-objects must be encoded before hashing In Python3 encoding is explicitly needed, using encode method or b"" it can be achieved. Hashing examples with python([1]) [1] https://www.pythoncentral.io/hashing-strings-with-python/ Change-Id: I17ca99f00492633fa8e9e15558096792a48d204b --- zaqar/storage/swift/claims.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaqar/storage/swift/claims.py b/zaqar/storage/swift/claims.py index 6990880f3..4bcfe9734 100644 --- a/zaqar/storage/swift/claims.py +++ b/zaqar/storage/swift/claims.py @@ -121,7 +121,7 @@ class ClaimController(storage.Claim): jsonutils.dumps( {'body': msg['body'], 'claim_id': None, 'ttl': msg['ttl'], - 'claim_count': claim_count})) + 'claim_count': claim_count}).encode('utf-8')) md5 = md5.hexdigest() msg_ttl = max(msg['ttl'], msg_ts) move_to_dlq = False @@ -224,7 +224,7 @@ class ClaimController(storage.Claim): except errors.MessageDoesNotExist: continue md5 = hashlib.md5() - md5.update(msg) + md5.update(msg.encode('utf-8')) md5 = md5.hexdigest() msg = jsonutils.loads(msg) content = jsonutils.dumps(