MCPcopy Index your code
hub / github.com/python/cpython / _openssl_hash

Function _openssl_hash

Lib/test/support/hashlib_helper.py:665–687  ·  view source on GitHub ↗

Check availability of _hashlib.openssl_ (**kwargs). The constructor function is returned (without binding **kwargs), or SkipTest is raised if none exists.

(digestname, /, **kwargs)

Source from the content-addressed store, hash-verified

663
664
665def _openssl_hash(digestname, /, **kwargs):
666 """Check availability of _hashlib.openssl_<digestname>(**kwargs).
667
668 The constructor function is returned (without binding **kwargs),
669 or SkipTest is raised if none exists.
670 """
671 assert isinstance(digestname, str), digestname
672 method_name = f"openssl_{digestname}"
673 fullname = f"_hashlib.{method_name}"
674 try:
675 # re-import '_hashlib' in case it was mocked
676 _hashlib = importlib.import_module("_hashlib")
677 except ImportError as exc:
678 raise SkipNoHash(fullname, "openssl") from exc
679 try:
680 constructor = getattr(_hashlib, method_name)
681 except AttributeError as exc:
682 raise SkipNoHash(fullname, "openssl") from exc
683 try:
684 constructor(**kwargs)
685 except ValueError as exc:
686 raise SkipNoHash(fullname, "openssl") from exc
687 return constructor
688
689
690def requires_hashdigest(digestname, openssl=None, *, usedforsecurity=True):

Callers 1

_find_constructorMethod · 0.85

Calls 3

SkipNoHashClass · 0.85
constructorFunction · 0.85
import_moduleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…