equal
deleted
inserted
replaced
20 |
20 |
21 from .i18n import _ |
21 from .i18n import _ |
22 from . import ( |
22 from . import ( |
23 encoding, |
23 encoding, |
24 error, |
24 error, |
|
25 pycompat, |
25 util, |
26 util, |
26 ) |
27 ) |
27 |
28 |
28 class parser(object): |
29 class parser(object): |
29 def __init__(self, elements, methods=None): |
30 def __init__(self, elements, methods=None): |
190 def unescapestr(s): |
191 def unescapestr(s): |
191 try: |
192 try: |
192 return util.unescapestr(s) |
193 return util.unescapestr(s) |
193 except ValueError as e: |
194 except ValueError as e: |
194 # mangle Python's exception into our format |
195 # mangle Python's exception into our format |
195 raise error.ParseError(str(e).lower()) |
196 raise error.ParseError(pycompat.bytestr(e).lower()) |
196 |
197 |
197 def _brepr(obj): |
198 def _brepr(obj): |
198 if isinstance(obj, bytes): |
199 if isinstance(obj, bytes): |
199 return b"'%s'" % util.escapestr(obj) |
200 return b"'%s'" % util.escapestr(obj) |
200 return encoding.strtolocal(repr(obj)) |
201 return encoding.strtolocal(repr(obj)) |