diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index ff4bfcdcc407b9..62b4e07f1423ba 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -43,19 +43,19 @@ def __reduce__(self): return self.__class__, (self.msg, self.doc, self.pos) -_CONSTANTS = { +_CONSTANTS = frozendict({ '-Infinity': NegInf, 'Infinity': PosInf, 'NaN': NaN, -} +}) HEXDIGITS = re.compile(r'[0-9A-Fa-f]{4}', FLAGS) STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS) -BACKSLASH = { +BACKSLASH = frozendict({ '"': '"', '\\': '\\', '/': '/', 'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t', -} +}) def _decode_uXXXX(s, pos, _m=HEXDIGITS.match): esc = _m(s, pos + 1) diff --git a/Lib/json/tool.py b/Lib/json/tool.py index 050c2fe2161e3e..14a5c9ecb74d13 100644 --- a/Lib/json/tool.py +++ b/Lib/json/tool.py @@ -22,13 +22,7 @@ (?Pnull) ''', re.VERBOSE) -_group_to_theme_color = { - "key": "definition", - "string": "string", - "number": "number", - "boolean": "keyword", - "null": "keyword", -} +_group_to_theme_color = frozendict(key="definition",string="string",number="number",boolean="keyword",null="keyword") def _colorize_json(json_str, theme):