@@ -279,7 +279,10 @@ def test_clinic_signature(self):
279
279
with self .assertWarnsRegex (DeprecationWarning ,
280
280
DEPRECATED_STRING_PARAMETER ):
281
281
hashlib .new (digest_name , string = b'' )
282
- if self ._hashlib :
282
+ # Make sure that _hashlib contains the constructor
283
+ # to test when using a combination of libcrypto and
284
+ # interned hash implementations.
285
+ if self ._hashlib and digest_name in self ._hashlib ._constructors :
283
286
self ._hashlib .new (digest_name , b'' )
284
287
self ._hashlib .new (digest_name , data = b'' )
285
288
with self .assertWarnsRegex (DeprecationWarning ,
@@ -333,7 +336,8 @@ def test_clinic_signature_errors(self):
333
336
with self .subTest (digest_name , args = args , kwds = kwds ):
334
337
with self .assertRaisesRegex (TypeError , errmsg ):
335
338
hashlib .new (digest_name , * args , ** kwds )
336
- if self ._hashlib :
339
+ if (self ._hashlib and
340
+ digest_name in self ._hashlib ._constructors ):
337
341
with self .assertRaisesRegex (TypeError , errmsg ):
338
342
self ._hashlib .new (digest_name , * args , ** kwds )
339
343
0 commit comments