Browse Source

Merge pull request #500 from rlaboiss/libravatar-fix-python3

libravatar: Encode email address before hashing
Justin Mayer 9 years ago
parent
commit
fb1d239135
1 changed files with 3 additions and 1 deletions
  1. 3 1
      libravatar/libravatar.py

+ 3 - 1
libravatar/libravatar.py

@@ -42,7 +42,9 @@ def add_libravatar (generator, metadata):
     if metadata ['email']:
 
         ## Compose URL using the MD5 hash
-        md5 = hashlib.md5 (metadata ['email'].lower ()).hexdigest ()
+        ## (the ascii encoding is necessary for Python3)
+        email = metadata ['email'].lower ().encode ('ascii')
+        md5 = hashlib.md5 (email).hexdigest ()
         url = 'http://cdn.libravatar.org/avatar/' + md5
 
         ## Add eventual "missing picture" option