Merge pull request #4221 from ashorin/unicode-md5

Prevent UnicodeEncodeError: 'ascii' codec can't encode characters in pos...
This commit is contained in:
James Cammarata 2013-09-27 08:50:44 -07:00
commit 039d4c95d9

View file

@ -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())
try:
digest.update(data)
except UnicodeEncodeError:
digest.update(data.encode('utf-8'))
return digest.hexdigest()
def md5(filename):