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

Function _block_builtin_hmac_digest

Lib/test/support/hashlib_helper.py:953–967  ·  view source on GitHub ↗
(blocked_name)

Source from the content-addressed store, hash-verified

951
952
953def _block_builtin_hmac_digest(blocked_name):
954 assert isinstance(blocked_name, str), blocked_name
955
956 # re-import '_hmac' in case it was mocked
957 if (_hmac := _import_module("_hmac")) is None:
958 return contextlib.nullcontext()
959
960 @functools.wraps(wrapped := _hmac.compute_digest)
961 def _hmac_compute_digest(key, msg, digest):
962 if digest == blocked_name:
963 raise _hmac.UnknownHashError(blocked_name)
964 return wrapped(key, msg, digest)
965
966 _ensure_wrapper_signature(_hmac_compute_digest, wrapped)
967 return unittest.mock.patch('_hmac.compute_digest', _hmac_compute_digest)
968
969
970def _make_hash_constructor_blocker(name, dummy, implementation):

Callers 1

block_algorithmFunction · 0.85

Calls 2

_import_moduleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…