MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / force_bytes

Function force_bytes

pre_commit/util.py:19–24  ·  view source on GitHub ↗
(exc: Any)

Source from the content-addressed store, hash-verified

17
18
19def force_bytes(exc: Any) -> bytes:
20 with contextlib.suppress(TypeError):
21 return bytes(exc)
22 with contextlib.suppress(Exception):
23 return str(exc).encode()
24 return f'<unprintable {type(exc).__name__} object>'.encode()
25
26
27@contextlib.contextmanager

Callers 2

_log_and_exitFunction · 0.90
_oserror_to_outputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected