mercurial/parser.py
changeset 48011 8655a77dce94
parent 46819 d4ba4d51f85f
child 48875 6000f5b25c9b
equal deleted inserted replaced
48010:ae79611e3115 48011:8655a77dce94
    19 from __future__ import absolute_import, print_function
    19 from __future__ import absolute_import, print_function
    20 
    20 
    21 from .i18n import _
    21 from .i18n import _
    22 from . import (
    22 from . import (
    23     error,
    23     error,
    24     pycompat,
       
    25     util,
    24     util,
    26 )
    25 )
    27 from .utils import stringutil
    26 from .utils import stringutil
    28 
    27 
    29 
    28 
   214 def unescapestr(s):
   213 def unescapestr(s):
   215     try:
   214     try:
   216         return stringutil.unescapestr(s)
   215         return stringutil.unescapestr(s)
   217     except ValueError as e:
   216     except ValueError as e:
   218         # mangle Python's exception into our format
   217         # mangle Python's exception into our format
   219         raise error.ParseError(pycompat.bytestr(e).lower())
   218         # TODO: remove this suppression.  For some reason, pytype 2021.09.09
       
   219         #   thinks .lower() is being called on Union[ValueError, bytes].
       
   220         # pytype: disable=attribute-error
       
   221         raise error.ParseError(stringutil.forcebytestr(e).lower())
       
   222         # pytype: enable=attribute-error
   220 
   223 
   221 
   224 
   222 def _prettyformat(tree, leafnodes, level, lines):
   225 def _prettyformat(tree, leafnodes, level, lines):
   223     if not isinstance(tree, tuple):
   226     if not isinstance(tree, tuple):
   224         lines.append((level, stringutil.pprint(tree)))
   227         lines.append((level, stringutil.pprint(tree)))