https://github.com/python/cpython/commit/065194c1a971b59547f1bb2cc64760c4bf0ee674
commit: 065194c1a971b59547f1bb2cc64760c4bf0ee674
branch: main
author: Will Childs-Klein <[email protected]>
committer: picnixz <[email protected]>
date: 2025-06-27T17:01:16+02:00
summary:
gh-135571: Guard `_hashlib` usage in `test_hashlib.py` (#135572)
files:
M Lib/test/test_hashlib.py
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 7b378c45e71563..5bad483ae9dafc 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -279,7 +279,10 @@ def test_clinic_signature(self):
with self.assertWarnsRegex(DeprecationWarning,
DEPRECATED_STRING_PARAMETER):
hashlib.new(digest_name, string=b'')
- if self._hashlib:
+ # Make sure that _hashlib contains the constructor
+ # to test when using a combination of libcrypto and
+ # interned hash implementations.
+ if self._hashlib and digest_name in
self._hashlib._constructors:
self._hashlib.new(digest_name, b'')
self._hashlib.new(digest_name, data=b'')
with self.assertWarnsRegex(DeprecationWarning,
@@ -333,7 +336,8 @@ def test_clinic_signature_errors(self):
with self.subTest(digest_name, args=args, kwds=kwds):
with self.assertRaisesRegex(TypeError, errmsg):
hashlib.new(digest_name, *args, **kwds)
- if self._hashlib:
+ if (self._hashlib and
+ digest_name in self._hashlib._constructors):
with self.assertRaisesRegex(TypeError, errmsg):
self._hashlib.new(digest_name, *args, **kwds)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]