MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / _try_decode

Function _try_decode

commitizen/cmd.py:24–36  ·  view source on GitHub ↗
(bytes_: bytes)

Source from the content-addressed store, hash-verified

22
23
24def _try_decode(bytes_: bytes) -> str:
25 try:
26 return bytes_.decode("utf-8")
27 except UnicodeDecodeError:
28 pass
29
30 charset_match = from_bytes(bytes_).best()
31 if charset_match is None:
32 raise CharacterSetDecodeError()
33 try:
34 return bytes_.decode(charset_match.encoding)
35 except UnicodeDecodeError as e:
36 raise CharacterSetDecodeError() from e
37
38
39def _popen(

Callers 1

_popenFunction · 0.85

Calls 2

decodeMethod · 0.80

Tested by

no test coverage detected