Skip to content

Commit 4b7ee88

Browse files
authored
Restore support for Python 2.7.0-2.7.8
`hashlib.algorithms_guaranteed` was introduced only in Python 2.7.9, see https://docs.python.org/2.7/library/hashlib.html#hashlib.algorithms_guaranteed Ubuntu 14.04 LTS (which will be supported until April 2019) still provides python 2.7.5 and therefore needs this fix. Tested on python 2.7.3, 2.7.5, 2.7.12 and 3.5.3.
1 parent c39b650 commit 4b7ee88

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

bagit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ def find_locale_dir():
122122
# Payload-Oxum is autogenerated
123123
]
124124

125-
CHECKSUM_ALGOS = hashlib.algorithms_guaranteed
125+
try:
126+
CHECKSUM_ALGOS = hashlib.algorithms_guaranteed
127+
except AttributeError:
128+
# Python 2.7.0-2.7.8
129+
CHECKSUM_ALGOS = set(hashlib.algorithms)
126130
DEFAULT_CHECKSUMS = ["sha256", "sha512"]
127131

128132
#: Block size used when reading files for hashing:

0 commit comments

Comments
 (0)