(val, maxlen, ellipsis='...')
| 117 | |
| 118 | |
| 119 | def _format_binary_bytes(val, maxlen, ellipsis='...'): |
| 120 | # type: (bytes, int, str) -> str |
| 121 | if maxlen and len(val) > maxlen: |
| 122 | # we don't want to copy all the data, just take what we need. |
| 123 | chunk = memoryview(val)[:maxlen].tobytes() |
| 124 | return _bytes_prefix(f"'{_repr_binary_bytes(chunk)}{ellipsis}'") |
| 125 | return _bytes_prefix(f"'{_repr_binary_bytes(val)}'") |
| 126 | |
| 127 | |
| 128 | def _bytes_prefix(s): |
no test coverage detected