mercurial/utils/stringutil.py
changeset 49648 9be765b82a90
parent 49575 bbbb5213d043
child 51686 493034cc3265
equal deleted inserted replaced
49646:2a70d1fc70c4 49648:9be765b82a90
   721     # "bytes" is also a typing shortcut for bytes, bytearray, and memoryview
   721     # "bytes" is also a typing shortcut for bytes, bytearray, and memoryview
   722     if isinstance(s, memoryview):
   722     if isinstance(s, memoryview):
   723         s = bytes(s)
   723         s = bytes(s)
   724     # call underlying function of s.encode('string_escape') directly for
   724     # call underlying function of s.encode('string_escape') directly for
   725     # Python 3 compatibility
   725     # Python 3 compatibility
       
   726     # pytype: disable=bad-return-type
   726     return codecs.escape_encode(s)[0]  # pytype: disable=module-attr
   727     return codecs.escape_encode(s)[0]  # pytype: disable=module-attr
       
   728     # pytype: enable=bad-return-type
   727 
   729 
   728 
   730 
   729 def unescapestr(s: bytes) -> bytes:
   731 def unescapestr(s: bytes) -> bytes:
       
   732     # pytype: disable=bad-return-type
   730     return codecs.escape_decode(s)[0]  # pytype: disable=module-attr
   733     return codecs.escape_decode(s)[0]  # pytype: disable=module-attr
       
   734     # pytype: enable=bad-return-type
   731 
   735 
   732 
   736 
   733 def forcebytestr(obj):
   737 def forcebytestr(obj):
   734     """Portably format an arbitrary object (e.g. exception) into a byte
   738     """Portably format an arbitrary object (e.g. exception) into a byte
   735     string."""
   739     string."""