diff options
Diffstat (limited to 'simplejson/decoder.py')
-rw-r--r-- | simplejson/decoder.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/simplejson/decoder.py b/simplejson/decoder.py index e0b55a4..0c3a45c 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -4,7 +4,7 @@ from __future__ import absolute_import import re import sys import struct -from .compat import u, text_type, binary_type, PY3, unichr +from .compat import PY3, unichr from .scanner import make_scanner, JSONDecodeError def _import_c_scanstring(): @@ -40,14 +40,14 @@ _CONSTANTS = { STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS) BACKSLASH = { - '"': u('"'), '\\': u('\u005c'), '/': u('/'), - 'b': u('\b'), 'f': u('\f'), 'n': u('\n'), 'r': u('\r'), 't': u('\t'), + '"': u'"', '\\': u'\\', '/': u'/', + 'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t', } DEFAULT_ENCODING = "utf-8" def py_scanstring(s, end, encoding=None, strict=True, - _b=BACKSLASH, _m=STRINGCHUNK.match, _join=u('').join, + _b=BACKSLASH, _m=STRINGCHUNK.match, _join=u''.join, _PY3=PY3, _maxunicode=sys.maxunicode): """Scan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. @@ -71,8 +71,8 @@ def py_scanstring(s, end, encoding=None, strict=True, content, terminator = chunk.groups() # Content is contains zero or more unescaped string characters if content: - if not _PY3 and not isinstance(content, text_type): - content = text_type(content, encoding) + if not _PY3 and not isinstance(content, unicode): + content = unicode(content, encoding) _append(content) # Terminator is the end of string, a literal control character, # or a backslash denoting that an escape sequence follows @@ -365,7 +365,7 @@ class JSONDecoder(object): instance containing a JSON document) """ - if _PY3 and isinstance(s, binary_type): + if _PY3 and isinstance(s, bytes): s = s.decode(self.encoding) obj, end = self.raw_decode(s) end = _w(s, end).end() @@ -388,7 +388,7 @@ class JSONDecoder(object): # Ensure that raw_decode bails on negative indexes, the regex # would otherwise mask this behavior. #98 raise JSONDecodeError('Expecting value', s, idx) - if _PY3 and not isinstance(s, text_type): + if _PY3 and not isinstance(s, str): raise TypeError("Input string must be text, not bytes") # strip UTF-8 bom if len(s) > idx: |