From 30a2bb5dcbdaecf5b9b46f448e3a0dd6a3c2abfa Mon Sep 17 00:00:00 2001 From: Will Childs-Klein Date: Fri, 27 Jun 2025 11:01:16 -0400 Subject: [PATCH] [3.13] gh-135571: Guard `_hashlib` usage in `test_hashlib.py` (GH-135572) (cherry picked from commit 065194c1a971b59547f1bb2cc64760c4bf0ee674) Co-authored-by: Will Childs-Klein --- Lib/test/test_hashlib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 56d2f70021235f..8eb0ac230bc770 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -264,7 +264,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'') @@ -316,7 +319,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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy