# HG changeset patch # User Franz Glasner # Date 1744229689 -7200 # Node ID d5c920ace3cbb4acfc961e1462a0edf5c92d0b46 # Parent bbfcdbd75bfe867f3ff09305ee6ed0badfb4023a treesum: FIX: Python<2.7.9 has no hashlib.algorithms_available: fall back to hashlib.algorithms in this case diff -r bbfcdbd75bfe -r d5c920ace3cb cutils/util/__init__.py --- a/cutils/util/__init__.py Fri Apr 04 19:14:20 2025 +0200 +++ b/cutils/util/__init__.py Wed Apr 09 22:14:49 2025 +0200 @@ -83,9 +83,17 @@ Does not consider :mod:`pyblake2` if it is available eventually. """ - if "blake2b" in hashlib.algorithms_available: + # Python <2.7.9 has no algorithms_available: fall back to algorithms + try: + algos = hashlib.algorithms_available + except AttributeError: + try: + algos = hashlib.algorithms + except AttributeError: + algos = [] + if "blake2b" in algos: return "BLAKE2b-256" - if "sha256" in hashlib.algorithms_available: + if "sha256" in algos: return "SHA256" return "SHA1"