mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Encode to utf-8 only when needed
This commit is contained in:
parent
21f5bc4242
commit
fd101dd2d6
1 changed files with 4 additions and 2 deletions
|
@ -408,9 +408,11 @@ def merge_hash(a, b):
|
||||||
def md5s(data):
|
def md5s(data):
|
||||||
''' Return MD5 hex digest of data. '''
|
''' Return MD5 hex digest of data. '''
|
||||||
|
|
||||||
buf = StringIO.StringIO(data)
|
|
||||||
digest = _md5()
|
digest = _md5()
|
||||||
digest.update(buf.read().encode('utf-8'))
|
try:
|
||||||
|
digest.update(data)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
digest.update(data.encode('utf-8'))
|
||||||
return digest.hexdigest()
|
return digest.hexdigest()
|
||||||
|
|
||||||
def md5(filename):
|
def md5(filename):
|
||||||
|
|
Loading…
Reference in a new issue