mercurial/utils/stringutil.py
changeset 51828 4eccb65e444f
parent 51725 278af66e6595
child 51859 f4733654f144
equal deleted inserted replaced
51827:34eb3a711955 51828:4eccb65e444f
   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