(s, encoding='utf-8', errors='strict')
| 80 | return s |
| 81 | |
| 82 | def 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 | |
| 90 | try: |