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

Function _block_builtin_hmac_constructor

Lib/test/support/hashlib_helper.py:1001–1014  ·  view source on GitHub ↗

Block explicit HACL* HMAC constructors.

(name)

Source from the content-addressed store, hash-verified

999
1000
1001def _block_builtin_hmac_constructor(name):
1002 """Block explicit HACL* HMAC constructors."""
1003 info = get_hmac_item_info(name)
1004 assert info.module_name is None or info.module_name == "_hmac", info
1005 if (wrapped := info.import_member()) is None:
1006 # function shouldn't exist for this implementation
1007 return contextlib.nullcontext()
1008
1009 @functools.wraps(wrapped)
1010 def wrapper(key, obj):
1011 raise ValueError(f"blocked hash name: {name}")
1012
1013 _ensure_wrapper_signature(wrapper, wrapped)
1014 return unittest.mock.patch(info.fullname, wrapper)
1015
1016
1017@contextlib.contextmanager

Callers 1

block_algorithmFunction · 0.85

Calls 3

get_hmac_item_infoFunction · 0.85
import_memberMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…