Merge "Bug fix: calculate md5 on non-unicode strings"
This commit is contained in:
@@ -93,9 +93,13 @@ def spawn(target, *args, **kwargs):
|
|||||||
|
|
||||||
def md5(obj):
|
def md5(obj):
|
||||||
if isinstance(obj, tuple):
|
if isinstance(obj, tuple):
|
||||||
obj = str(obj)
|
obj = str([str(o) for o in obj])
|
||||||
|
|
||||||
if isinstance(obj, six.string_types):
|
if isinstance(obj, six.string_types):
|
||||||
return hashlib.md5(six.b(obj)).hexdigest()
|
if six.PY2:
|
||||||
|
return hashlib.md5(obj).hexdigest()
|
||||||
|
else:
|
||||||
|
return hashlib.md5(obj.encode('utf-8')).hexdigest()
|
||||||
raise Exception('Unknown object for md5 %s', str(obj))
|
raise Exception('Unknown object for md5 %s', str(obj))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user