mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Modify the correct variable when setting available hashing algorithms (#52994)
* Revert "use list instead of tuple and remove md5 on ValueError (#51357)" c459f040da
.
* Modify the correct variable when determining available hashing algorithms
This commit is contained in:
parent
644362d0be
commit
23a6b88dd2
3 changed files with 4 additions and 7 deletions
|
@ -129,12 +129,10 @@ try:
|
|||
for attribute in ('available_algorithms', 'algorithms'):
|
||||
algorithms = getattr(hashlib, attribute, None)
|
||||
if algorithms:
|
||||
# convert algorithms to list instead of immutable tuple so md5 can be removed if not available
|
||||
algorithms = list(algorithms)
|
||||
break
|
||||
if algorithms is None:
|
||||
# python 2.5+
|
||||
algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
|
||||
algorithms = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
|
||||
for algorithm in algorithms:
|
||||
AVAILABLE_HASH_ALGORITHMS[algorithm] = getattr(hashlib, algorithm)
|
||||
|
||||
|
@ -142,7 +140,7 @@ try:
|
|||
try:
|
||||
hashlib.md5()
|
||||
except ValueError:
|
||||
algorithms.remove('md5')
|
||||
AVAILABLE_HASH_ALGORITHMS.pop('md5', None)
|
||||
except Exception:
|
||||
import sha
|
||||
AVAILABLE_HASH_ALGORITHMS = {'sha1': sha.sha}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue