From 910081d515bc7cd8ac8956da16ee2992a09ec360 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 4 Aug 2014 18:09:30 +1000 Subject: [PATCH] sb: Fix using hashlib's algorithms on python earlier than 2.7. --- source-builder/sb/download.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source-builder/sb/download.py b/source-builder/sb/download.py index 51747b1..df448e0 100644 --- a/source-builder/sb/download.py +++ b/source-builder/sb/download.py @@ -58,7 +58,11 @@ def _hash_check(file_, absfile, macros, remove = True): hash = hash.split() if len(hash) != 2: raise error.internal('invalid hash format: %s' % (file_)) - if hash[0] not in hashlib.algorithms: + try: + hashlib_algorithms = hashlib.algorithms + except: + hashlib_algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'] + if hash[0] not in hashlib_algorithms: raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0])) hasher = None _in = None