Python 3.6: Fixed issue with gravatar function

Hashing of string object doesn't work. Also added a deprecation warning
that pillar.api.utils.gravatar should be used; pillar.web.utils.gravatar
is just a copy.
This commit is contained in:
2017-03-03 14:42:13 +01:00
parent dcdcd99393
commit ae5009c9ef
2 changed files with 9 additions and 7 deletions

View File

@@ -141,10 +141,10 @@ def str2id(document_id):
raise wz_exceptions.BadRequest('Invalid object ID %r' % document_id)
def gravatar(email, size=64):
def gravatar(email: str, size=64):
parameters = {'s': str(size), 'd': 'mm'}
return "https://www.gravatar.com/avatar/" + \
hashlib.md5(str(email)).hexdigest() + \
hashlib.md5(email.encode()).hexdigest() + \
"?" + urllib.parse.urlencode(parameters)