(f: Callable[P, T])
| 494 | |
| 495 | |
| 496 | def libgit2_callback(f: Callable[P, T]) -> Callable[P, T]: |
| 497 | @wraps(f) |
| 498 | def wrapper(*args): |
| 499 | data = ffi.from_handle(args[-1]) |
| 500 | args = args[:-1] + (data,) |
| 501 | try: |
| 502 | return f(*args) |
| 503 | except Passthrough: |
| 504 | # A user defined callback can raise Passthrough to decline to act; |
| 505 | # then libgit2 will behave as if there was no callback set in the |
| 506 | # first place. |
| 507 | return C.GIT_PASSTHROUGH |
| 508 | except BaseException as e: |
| 509 | # Keep the exception to be re-raised later, and inform libgit2 that |
| 510 | # the user defined callback has failed. |
| 511 | data._stored_exception = e |
| 512 | return C.GIT_EUSER |
| 513 | |
| 514 | return ffi.def_extern()(wrapper) # type: ignore[attr-defined] |
| 515 | |
| 516 | |
| 517 | def libgit2_callback_void(f: Callable[P, T]) -> Callable[P, T]: |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…