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

Function _block_builtin_hmac_new

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

Source from the content-addressed store, hash-verified

934
935
936def _block_builtin_hmac_new(blocked_name):
937 assert isinstance(blocked_name, str), blocked_name
938
939 # re-import '_hmac' in case it was mocked
940 if (_hmac := _import_module("_hmac")) is None:
941 return contextlib.nullcontext()
942
943 @functools.wraps(wrapped := _hmac.new)
944 def _hmac_new(key, msg=None, digestmod=None):
945 if digestmod == blocked_name:
946 raise _hmac.UnknownHashError(blocked_name)
947 return wrapped(key, msg, digestmod)
948
949 _ensure_wrapper_signature(_hmac_new, wrapped)
950 return unittest.mock.patch('_hmac.new', _hmac_new)
951
952
953def _block_builtin_hmac_digest(blocked_name):

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…