https://github.com/python/cpython/commit/c9c51bd770e6536e450477a61374f9911dc07135 commit: c9c51bd770e6536e450477a61374f9911dc07135 branch: 3.14 author: Bénédikt Tran <10796600+picn...@users.noreply.github.com> committer: picnixz <10796600+picn...@users.noreply.github.com> date: 2025-06-28T10:15:39+02:00 summary:
[3.14] gh-135571: Guard `_hashlib` usage in `test_hashlib.py` (GH-135572) (#136042) (cherry picked from commit 065194c1a971b59547f1bb2cc64760c4bf0ee674) Co-authored-by: Will Childs-Klein <willc...@gmail.com> files: M Lib/test/test_hashlib.py diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index e25a938562a938..959fe90ff01d47 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -263,7 +263,10 @@ def test_clinic_signature(self): hashlib.new(digest_name, b'') hashlib.new(digest_name, data=b'') 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'') self._hashlib.new(digest_name, string=b'') @@ -315,7 +318,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 -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: arch...@mail-archive.com