(blocked_name)
| 951 | |
| 952 | |
| 953 | def _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 | |
| 970 | def _make_hash_constructor_blocker(name, dummy, implementation): |
no test coverage detected
searching dependent graphs…