MCPcopy Index your code
hub / github.com/RustPython/RustPython / _bytes_from_decode_data

Function _bytes_from_decode_data

Lib/base64.py:31–43  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

29bytes_types = (bytes, bytearray) # Types acceptable as binary data
30
31def _bytes_from_decode_data(s):
32 if isinstance(s, str):
33 try:
34 return s.encode('ascii')
35 except UnicodeEncodeError:
36 raise ValueError('string argument should contain only ASCII characters')
37 if isinstance(s, bytes_types):
38 return s
39 try:
40 return memoryview(s).tobytes()
41 except TypeError:
42 raise TypeError("argument should be a bytes-like object or ASCII "
43 "string, not %r" % s.__class__.__name__) from None
44
45
46# Base64 encoding/decoding uses binascii

Callers 7

b64decodeFunction · 0.85
urlsafe_b64decodeFunction · 0.85
_b32decodeFunction · 0.85
b16decodeFunction · 0.85
a85decodeFunction · 0.85
b85decodeFunction · 0.85
z85decodeFunction · 0.85

Calls 3

isinstanceFunction · 0.85
encodeMethod · 0.45
tobytesMethod · 0.45

Tested by

no test coverage detected