Commit fd101dd2 by Andrey Shorin

Encode to utf-8 only when needed

parent 21f5bc42
......@@ -408,9 +408,11 @@ def merge_hash(a, b):
def md5s(data):
''' Return MD5 hex digest of data. '''
buf = StringIO.StringIO(data)
digest = _md5()
digest.update(buf.read().encode('utf-8'))
try:
digest.update(data)
except UnicodeEncodeError:
digest.update(data.encode('utf-8'))
return digest.hexdigest()
def md5(filename):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment