]> code.ossystems Code Review - openembedded-core.git/commitdiff
spdx.bbclass: Encode strings before passing to hashlib
authorOlof Johansson <olof.johansson@axis.com>
Mon, 16 Jul 2018 15:05:56 +0000 (17:05 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 18 Jul 2018 09:13:30 +0000 (10:13 +0100)
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@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/spdx.bbclass

index a3e22afc33d87435aa430a6a54072b1887317e42..fb78e274a8edf308d0f16eeb6d1c3ee220055774 100644 (file)
@@ -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):