Show More
@@ -32,7 +32,7 b' def _string_escape(text):' | |||
|
32 | 32 | >>> s |
|
33 | 33 | 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' |
|
34 | 34 | >>> res = _string_escape(s) |
|
35 | >>> s == res.decode('string_escape') | |
|
35 | >>> s == util.unescapestr(res) | |
|
36 | 36 | True |
|
37 | 37 | """ |
|
38 | 38 | # subset of the string_escape codec |
@@ -57,7 +57,7 b' def decodeextra(text):' | |||
|
57 | 57 | l = l.replace('\\\\', '\\\\\n') |
|
58 | 58 | l = l.replace('\\0', '\0') |
|
59 | 59 | l = l.replace('\n', '') |
|
60 |
k, v = l |
|
|
60 | k, v = util.unescapestr(l).split(':', 1) | |
|
61 | 61 | extra[k] = v |
|
62 | 62 | return extra |
|
63 | 63 |
@@ -19,7 +19,10 b'' | |||
|
19 | 19 | from __future__ import absolute_import |
|
20 | 20 | |
|
21 | 21 | from .i18n import _ |
|
22 |
from . import |
|
|
22 | from . import ( | |
|
23 | error, | |
|
24 | util, | |
|
25 | ) | |
|
23 | 26 | |
|
24 | 27 | class parser(object): |
|
25 | 28 | def __init__(self, elements, methods=None): |
@@ -164,7 +167,7 b' def buildargsdict(trees, funcname, argsp' | |||
|
164 | 167 | |
|
165 | 168 | def unescapestr(s): |
|
166 | 169 | try: |
|
167 |
return s |
|
|
170 | return util.unescapestr(s) | |
|
168 | 171 | except ValueError as e: |
|
169 | 172 | # mangle Python's exception into our format |
|
170 | 173 | raise error.ParseError(str(e).lower()) |
@@ -2137,6 +2137,9 b' def escapestr(s):' | |||
|
2137 | 2137 | # Python 3 compatibility |
|
2138 | 2138 | return codecs.escape_encode(s)[0] |
|
2139 | 2139 | |
|
2140 | def unescapestr(s): | |
|
2141 | return s.decode('string_escape') | |
|
2142 | ||
|
2140 | 2143 | def uirepr(s): |
|
2141 | 2144 | # Avoid double backslash in Windows path repr() |
|
2142 | 2145 | return repr(s).replace('\\\\', '\\') |
General Comments 0
You need to be logged in to leave comments.
Login now