We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ae0915 commit a30cf41Copy full SHA for a30cf41
1 file changed
Lib/test/test_hashlib.py
@@ -40,16 +40,15 @@
40
openssl_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
41
42
try:
43
- from _hashlib import HASH
+ import _hashlib
44
except ImportError:
45
- HASH = None
46
-
47
-try:
48
- from _hashlib import HASHXOF, openssl_md_meth_names, get_fips_mode
49
-except ImportError:
50
- HASHXOF = None
51
- openssl_md_meth_names = frozenset()
52
+ _hashlib = None
+# The extension module may exist but only define some of these. gh-141907
+HASH = getattr(_hashlib, 'HASH', None)
+HASHXOF = getattr(_hashlib, 'HASHXOF', None)
+openssl_md_meth_names = getattr(_hashlib, 'openssl_md_meth_names', frozenset())
+get_fips_mode = getattr(_hashlib, 'get_fips_mode', None)
+if not get_fips_mode:
53
def get_fips_mode():
54
return 0
55
0 commit comments