diff options
Diffstat (limited to 'contrib/tools/python3/Lib/json')
-rw-r--r-- | contrib/tools/python3/Lib/json/decoder.py | 9 | ||||
-rw-r--r-- | contrib/tools/python3/Lib/json/scanner.py | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/contrib/tools/python3/Lib/json/decoder.py b/contrib/tools/python3/Lib/json/decoder.py index c5d9ae2d0d..5e5effeac0 100644 --- a/contrib/tools/python3/Lib/json/decoder.py +++ b/contrib/tools/python3/Lib/json/decoder.py @@ -50,17 +50,18 @@ _CONSTANTS = { } +HEXDIGITS = re.compile(r'[0-9A-Fa-f]{4}', FLAGS) STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS) BACKSLASH = { '"': '"', '\\': '\\', '/': '/', 'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t', } -def _decode_uXXXX(s, pos): - esc = s[pos + 1:pos + 5] - if len(esc) == 4 and esc[1] not in 'xX': +def _decode_uXXXX(s, pos, _m=HEXDIGITS.match): + esc = _m(s, pos + 1) + if esc is not None: try: - return int(esc, 16) + return int(esc.group(), 16) except ValueError: pass msg = "Invalid \\uXXXX escape" diff --git a/contrib/tools/python3/Lib/json/scanner.py b/contrib/tools/python3/Lib/json/scanner.py index 7a61cfc2d2..090897515f 100644 --- a/contrib/tools/python3/Lib/json/scanner.py +++ b/contrib/tools/python3/Lib/json/scanner.py @@ -9,7 +9,7 @@ except ImportError: __all__ = ['make_scanner'] NUMBER_RE = re.compile( - r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?', + r'(-?(?:0|[1-9][0-9]*))(\.[0-9]+)?([eE][-+]?[0-9]+)?', (re.VERBOSE | re.MULTILINE | re.DOTALL)) def py_make_scanner(context): |