MCPcopy Create free account
hub / github.com/getsentry/sentry / BytesCodec

Class BytesCodec

src/sentry/utils/codecs.py:52–65  ·  view source on GitHub ↗

Encode/decode strings to/from bytes using the encoding provided to the constructor.

Source from the content-addressed store, hash-verified

50
51
52class BytesCodec(Codec[str, bytes]):
53 """
54 Encode/decode strings to/from bytes using the encoding provided to the
55 constructor.
56 """
57
58 def __init__(self, encoding: str = "utf8"):
59 self.encoding = encoding
60
61 def encode(self, value: str) -> bytes:
62 return value.encode(self.encoding)
63
64 def decode(self, value: bytes) -> str:
65 return value.decode(self.encoding)
66
67
68class JSONCodec(Codec[Any, str]):

Callers 4

__init__Method · 0.90
test_codec_chainingFunction · 0.90
test_encoding_wrapperFunction · 0.90
test_redis_cache_compatFunction · 0.90

Calls

no outgoing calls

Tested by 3

test_codec_chainingFunction · 0.72
test_encoding_wrapperFunction · 0.72
test_redis_cache_compatFunction · 0.72