(s)
| 30 | bytes_types = (bytes, bytearray) # Types acceptable as binary data |
| 31 | |
| 32 | def _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 |
no test coverage detected
searching dependent graphs…