[PATCH 4/4] Encode str/unicode object before hashing it

Vratislav Podzimek vpodzime at redhat.com
Mon Dec 8 09:35:47 UTC 2014


hashlib requires a byte string so in Python3 we should encode the unicode
object. In Python2 encoding byte string makes no change.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 meh/dump.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meh/dump.py b/meh/dump.py
index faa5008..157a6a3 100644
--- a/meh/dump.py
+++ b/meh/dump.py
@@ -506,7 +506,7 @@ class ExceptionDump(object):
         else:
             s = "%s %s" % (self.type, self.value)
 
-        return hashlib.sha256(s).hexdigest()
+        return hashlib.sha256(s.encode("utf-8")).hexdigest()
 
     def traceback_and_object_dump(self, obj):
         """
-- 
1.9.3



More information about the anaconda-patches mailing list