Skip to content

Commit f1248cf

Browse files
[3.14] gh-137412: fix default_builtin_hashes values in test_hashlib.py (GH-137413) (#137534)
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent 3df0842 commit f1248cf

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Lib/test/test_hashlib.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,17 @@
2828
from http.client import HTTPException
2929

3030

31-
default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
31+
default_builtin_hashes = {'md5', 'sha1', 'sha2', 'sha3', 'blake2'}
3232
# --with-builtin-hashlib-hashes override
3333
builtin_hashes = sysconfig.get_config_var("PY_BUILTIN_HASHLIB_HASHES")
3434
if builtin_hashes is None:
3535
builtin_hashes = default_builtin_hashes
3636
else:
37-
builtin_hashes = {
38-
m.strip() for m in builtin_hashes.strip('"').lower().split(",")
39-
}
37+
builtin_hash_names = builtin_hashes.strip('"').lower().split(",")
38+
builtin_hashes = set(map(str.strip, builtin_hash_names))
4039

41-
# hashlib with and without OpenSSL backend for PBKDF2
42-
# only import builtin_hashlib when all builtin hashes are available.
43-
# Otherwise import prints noise on stderr
40+
# Public 'hashlib' module with OpenSSL backend for PBKDF2.
4441
openssl_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
45-
if builtin_hashes == default_builtin_hashes:
46-
builtin_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
47-
else:
48-
builtin_hashlib = None
4942

5043
try:
5144
from _hashlib import HASH, HASHXOF, openssl_md_meth_names, get_fips_mode

0 commit comments

Comments
 (0)