MCPcopy Create free account
hub / github.com/aws/aws-cli / ensure_bytes

Function ensure_bytes

awscli/botocore/compat.py:82–87  ·  view source on GitHub ↗
(s, encoding='utf-8', errors='strict')

Source from the content-addressed store, hash-verified

80 return s
81
82def ensure_bytes(s, encoding='utf-8', errors='strict'):
83 if isinstance(s, str):
84 return s.encode(encoding, errors)
85 if isinstance(s, bytes):
86 return s
87 raise ValueError(f"Expected str or bytes, received {type(s)}.")
88
89
90try:

Callers 8

test_stringMethod · 0.90
test_binaryMethod · 0.90
test_unicodeMethod · 0.90
test_non_asciiMethod · 0.90
_chunkedMethod · 0.90
serializeMethod · 0.90

Calls 1

encodeMethod · 0.45

Tested by 5

test_stringMethod · 0.72
test_binaryMethod · 0.72
test_unicodeMethod · 0.72
test_non_asciiMethod · 0.72