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"<string>" it can be achieved. Hashing examples with python([1]) [1] https://www.pythoncentral.io/hashing-strings-with-python/ Change-Id: I17ca99f00492633fa8e9e15558096792a48d204b
This commit is contained in:
parent
53b7115144
commit
7c2d6a970d
@ -121,7 +121,7 @@ class ClaimController(storage.Claim):
|
|||||||
jsonutils.dumps(
|
jsonutils.dumps(
|
||||||
{'body': msg['body'], 'claim_id': None,
|
{'body': msg['body'], 'claim_id': None,
|
||||||
'ttl': msg['ttl'],
|
'ttl': msg['ttl'],
|
||||||
'claim_count': claim_count}))
|
'claim_count': claim_count}).encode('utf-8'))
|
||||||
md5 = md5.hexdigest()
|
md5 = md5.hexdigest()
|
||||||
msg_ttl = max(msg['ttl'], msg_ts)
|
msg_ttl = max(msg['ttl'], msg_ts)
|
||||||
move_to_dlq = False
|
move_to_dlq = False
|
||||||
@ -224,7 +224,7 @@ class ClaimController(storage.Claim):
|
|||||||
except errors.MessageDoesNotExist:
|
except errors.MessageDoesNotExist:
|
||||||
continue
|
continue
|
||||||
md5 = hashlib.md5()
|
md5 = hashlib.md5()
|
||||||
md5.update(msg)
|
md5.update(msg.encode('utf-8'))
|
||||||
md5 = md5.hexdigest()
|
md5 = md5.hexdigest()
|
||||||
msg = jsonutils.loads(msg)
|
msg = jsonutils.loads(msg)
|
||||||
content = jsonutils.dumps(
|
content = jsonutils.dumps(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user