MCPcopy Index your code
hub / github.com/python/cpython / _bytes_from_decode_data

Function _bytes_from_decode_data

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

Source from the content-addressed store, hash-verified

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

Callers 5

b64decodeFunction · 0.85
urlsafe_b64decodeFunction · 0.85
b32decodeFunction · 0.85
b32hexdecodeFunction · 0.85
b16decodeFunction · 0.85

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…