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

Function _ensure_wrapper_signature

Lib/test/support/hashlib_helper.py:540–558  ·  view source on GitHub ↗

Ensure that a wrapper has the same signature as the wrapped function. This is used to guarantee that a TypeError raised due to a bad API call is raised consistently (using variadic signatures would hide such errors).

(wrapper, wrapped)

Source from the content-addressed store, hash-verified

538
539
540def _ensure_wrapper_signature(wrapper, wrapped):
541 """Ensure that a wrapper has the same signature as the wrapped function.
542
543 This is used to guarantee that a TypeError raised due to a bad API call
544 is raised consistently (using variadic signatures would hide such errors).
545 """
546 try:
547 wrapped_sig = inspect.signature(wrapped)
548 except ValueError: # built-in signature cannot be found
549 return
550
551 wrapper_sig = inspect.signature(wrapper)
552 if wrapped_sig != wrapper_sig:
553 fullname = f"{wrapped.__module__}.{wrapped.__qualname__}"
554 raise AssertionError(
555 f"signature for {fullname}() is incorrect:\n"
556 f" expect: {wrapped_sig}\n"
557 f" actual: {wrapper_sig}"
558 )
559
560
561def _make_conditional_decorator(test, /, *test_args, **test_kwargs):

Calls 1

signatureMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…