Mercurial > hg
comparison mercurial/parser.py @ 48041:37a41267d000
branching: merge stable into default
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 28 Sep 2021 09:40:57 +0200 |
parents | 8655a77dce94 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48040:7970895a21cb | 48041:37a41267d000 |
---|---|
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))) |