Adds the hashlib.algorithms attribute. See issue7418.
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index 5ecca2b..48f2cfd 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -58,7 +58,9 @@
# always available algorithm is added.
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
-__all__ = __always_supported + ('new',)
+algorithms = __always_supported
+
+__all__ = __always_supported + ('new', 'algorithms')
def __get_builtin_constructor(name):
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 6ef5557..8710dd6 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -102,6 +102,11 @@
c = cons(a)
c.hexdigest()
+ def test_algorithms_attribute(self):
+ self.assertEqual(hashlib.algorithms,
+ tuple([_algo for _algo in self.supported_hash_names if
+ _algo.islower()]))
+
def test_unknown_hash(self):
try:
hashlib.new('spam spam spam spam spam')