[OE-core] [PATCH 4/4] spdx.bbclass: Encode strings before passing to hashlib

Olof Johansson olof.johansson at axis.com
Mon Jul 16 15:05:56 UTC 2018


In python3, passing a unicode object to hashlib will result in an
exception that encourages you to encode it first.

Signed-off-by: Olof Johansson <olofjn at axis.com>
---
 meta/classes/spdx.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index a3e22afc33d..fb78e274a8e 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -208,7 +208,7 @@ def hash_file(file_name):
 def hash_string(data):
     import hashlib
     sha1 = hashlib.sha1()
-    sha1.update(data)
+    sha1.update(data.encode('utf-8'))
     return sha1.hexdigest()
 
 def run_fossology(foss_command, full_spdx):
-- 
2.11.0




More information about the Openembedded-core mailing list