equal
deleted
inserted
replaced
722 return encoding.trim(text, maxlength, ellipsis=b'...') |
722 return encoding.trim(text, maxlength, ellipsis=b'...') |
723 |
723 |
724 |
724 |
725 def escapestr(s: bytes) -> bytes: |
725 def escapestr(s: bytes) -> bytes: |
726 # "bytes" is also a typing shortcut for bytes, bytearray, and memoryview |
726 # "bytes" is also a typing shortcut for bytes, bytearray, and memoryview |
727 if isinstance(s, memoryview): |
727 if isinstance(s, (memoryview, bytearray)): |
728 s = bytes(s) |
728 s = bytes(s) |
729 # call underlying function of s.encode('string_escape') directly for |
729 # call underlying function of s.encode('string_escape') directly for |
730 # Python 3 compatibility |
730 # Python 3 compatibility |
731 # pytype: disable=bad-return-type |
731 # pytype: disable=bad-return-type |
732 return codecs.escape_encode(s)[0] # pytype: disable=module-attr |
732 return codecs.escape_encode(s)[0] # pytype: disable=module-attr |