mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Merge pull request #879 from JackDandy/feature/UpdateSimpleJSON
Update SimpleJSON library 3.8.1 (6022794) to 3.10.0 (c52efea).
This commit is contained in:
commit
7185b846ee
6 changed files with 60 additions and 17 deletions
|
@ -20,6 +20,7 @@
|
|||
* Update profilehooks 1.8.2.dev0 (ee3f1a8) to 1.9.0 (de7d59b)
|
||||
* Update rarfile to 3.0 (3e54b22)
|
||||
* Update Requests library 2.9.1 (a1c9b84) to 2.13.0 (fc54869)
|
||||
* Update SimpleJSON library 3.8.1 (6022794) to 3.10.0 (c52efea)
|
||||
|
||||
|
||||
[develop changelog]
|
||||
|
|
|
@ -97,7 +97,7 @@ Using simplejson.tool from the shell to validate and pretty-print::
|
|||
Expecting property name: line 1 column 3 (char 2)
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
__version__ = '3.8.1'
|
||||
__version__ = '3.10.0'
|
||||
__all__ = [
|
||||
'dump', 'dumps', 'load', 'loads',
|
||||
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
|
||||
|
@ -110,7 +110,7 @@ from decimal import Decimal
|
|||
|
||||
from .scanner import JSONDecodeError
|
||||
from .decoder import JSONDecoder
|
||||
from .encoder import JSONEncoder, JSONEncoderForHTML
|
||||
from .encoder import JSONEncoder, JSONEncoderForHTML, RawJSON
|
||||
def _import_OrderedDict():
|
||||
import collections
|
||||
try:
|
||||
|
|
|
@ -245,6 +245,8 @@ static void
|
|||
encoder_dealloc(PyObject *self);
|
||||
static int
|
||||
encoder_clear(PyObject *self);
|
||||
static int
|
||||
is_raw_json(PyObject *obj);
|
||||
static PyObject *
|
||||
encoder_stringify_key(PyEncoderObject *s, PyObject *key);
|
||||
static int
|
||||
|
@ -277,6 +279,20 @@ moduleinit(void);
|
|||
|
||||
#define MIN_EXPANSION 6
|
||||
|
||||
static PyObject* RawJSONType;
|
||||
static int
|
||||
is_raw_json(PyObject *obj)
|
||||
{
|
||||
if (RawJSONType == NULL) {
|
||||
PyObject *encoder_module = PyImport_ImportModule("simplejson.encoder");
|
||||
RawJSONType = PyObject_GetAttrString(encoder_module, "RawJSON");
|
||||
Py_DECREF(encoder_module);
|
||||
if (RawJSONType == NULL)
|
||||
return 0;
|
||||
}
|
||||
return PyObject_IsInstance(obj, RawJSONType) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
JSON_Accu_Init(JSON_Accu *acc)
|
||||
{
|
||||
|
@ -2654,7 +2670,7 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
if (PyInt_Check(int_as_string_bitcount) || PyLong_Check(int_as_string_bitcount)) {
|
||||
static const unsigned int long_long_bitsize = SIZEOF_LONG_LONG * 8;
|
||||
int int_as_string_bitcount_val = (int)PyLong_AsLong(int_as_string_bitcount);
|
||||
if (int_as_string_bitcount_val > 0 && int_as_string_bitcount_val < long_long_bitsize) {
|
||||
if (int_as_string_bitcount_val > 0 && int_as_string_bitcount_val < (int)long_long_bitsize) {
|
||||
s->max_long_size = PyLong_FromUnsignedLongLong(1ULL << int_as_string_bitcount_val);
|
||||
s->min_long_size = PyLong_FromLongLong(-1LL << int_as_string_bitcount_val);
|
||||
if (s->min_long_size == NULL || s->max_long_size == NULL) {
|
||||
|
@ -2868,6 +2884,12 @@ encoder_listencode_obj(PyEncoderObject *s, JSON_Accu *rval, PyObject *obj, Py_ss
|
|||
if (encoded != NULL)
|
||||
rv = _steal_accumulate(rval, encoded);
|
||||
}
|
||||
else if (is_raw_json(obj))
|
||||
{
|
||||
PyObject *encoded = PyObject_GetAttrString(obj, "encoded_json");
|
||||
if (encoded != NULL)
|
||||
rv = _steal_accumulate(rval, encoded);
|
||||
}
|
||||
else if (PyInt_Check(obj) || PyLong_Check(obj)) {
|
||||
PyObject *encoded;
|
||||
if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj)) {
|
||||
|
|
|
@ -15,9 +15,6 @@ if sys.version_info[0] < 3:
|
|||
integer_types = (int, long)
|
||||
unichr = unichr
|
||||
reload_module = reload
|
||||
def fromhex(s):
|
||||
return s.decode('hex')
|
||||
|
||||
else:
|
||||
PY3 = True
|
||||
if sys.version_info[:2] >= (3, 4):
|
||||
|
@ -40,7 +37,4 @@ else:
|
|||
def unichr(s):
|
||||
return u(chr(s))
|
||||
|
||||
def fromhex(s):
|
||||
return bytes.fromhex(s)
|
||||
|
||||
long_type = integer_types[-1]
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import absolute_import
|
|||
import re
|
||||
import sys
|
||||
import struct
|
||||
from .compat import fromhex, b, u, text_type, binary_type, PY3, unichr
|
||||
from .compat import b, u, text_type, binary_type, PY3, unichr
|
||||
from .scanner import make_scanner, JSONDecodeError
|
||||
|
||||
def _import_c_scanstring():
|
||||
|
@ -22,12 +22,16 @@ __all__ = ['JSONDecoder']
|
|||
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
||||
|
||||
def _floatconstants():
|
||||
_BYTES = fromhex('7FF80000000000007FF0000000000000')
|
||||
# The struct module in Python 2.4 would get frexp() out of range here
|
||||
# when an endian is specified in the format string. Fixed in Python 2.5+
|
||||
if sys.byteorder != 'big':
|
||||
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
|
||||
nan, inf = struct.unpack('dd', _BYTES)
|
||||
if sys.version_info < (2, 6):
|
||||
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
|
||||
# The struct module in Python 2.4 would get frexp() out of range here
|
||||
# when an endian is specified in the format string. Fixed in Python 2.5+
|
||||
if sys.byteorder != 'big':
|
||||
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
|
||||
nan, inf = struct.unpack('dd', _BYTES)
|
||||
else:
|
||||
nan = float('nan')
|
||||
inf = float('inf')
|
||||
return nan, inf, -inf
|
||||
|
||||
NaN, PosInf, NegInf = _floatconstants()
|
||||
|
|
|
@ -5,7 +5,7 @@ import re
|
|||
from operator import itemgetter
|
||||
# Do not import Decimal directly to avoid reload issues
|
||||
import decimal
|
||||
from .compat import u, unichr, binary_type, string_types, integer_types, PY3
|
||||
from .compat import u, unichr, binary_type, text_type, string_types, integer_types, PY3
|
||||
def _import_speedups():
|
||||
try:
|
||||
from . import _speedups
|
||||
|
@ -39,6 +39,14 @@ for i in [0x2028, 0x2029]:
|
|||
|
||||
FLOAT_REPR = repr
|
||||
|
||||
class RawJSON(object):
|
||||
"""Wrap an encoded JSON document for direct embedding in the output
|
||||
|
||||
"""
|
||||
def __init__(self, encoded_json):
|
||||
self.encoded_json = encoded_json
|
||||
|
||||
|
||||
def encode_basestring(s, _PY3=PY3, _q=u('"')):
|
||||
"""Return a JSON representation of a Python string
|
||||
|
||||
|
@ -46,9 +54,13 @@ def encode_basestring(s, _PY3=PY3, _q=u('"')):
|
|||
if _PY3:
|
||||
if isinstance(s, binary_type):
|
||||
s = s.decode('utf-8')
|
||||
if type(s) is not text_type:
|
||||
s = text_type(s)
|
||||
else:
|
||||
if isinstance(s, str) and HAS_UTF8.search(s) is not None:
|
||||
s = s.decode('utf-8')
|
||||
if type(s) not in string_types:
|
||||
s = text_type(s)
|
||||
def replace(match):
|
||||
return ESCAPE_DCT[match.group(0)]
|
||||
return _q + ESCAPE.sub(replace, s) + _q
|
||||
|
@ -61,9 +73,13 @@ def py_encode_basestring_ascii(s, _PY3=PY3):
|
|||
if _PY3:
|
||||
if isinstance(s, binary_type):
|
||||
s = s.decode('utf-8')
|
||||
if type(s) is not text_type:
|
||||
s = text_type(s)
|
||||
else:
|
||||
if isinstance(s, str) and HAS_UTF8.search(s) is not None:
|
||||
s = s.decode('utf-8')
|
||||
if type(s) not in string_types:
|
||||
s = text_type(s)
|
||||
def replace(match):
|
||||
s = match.group(0)
|
||||
try:
|
||||
|
@ -464,6 +480,8 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
|
|||
if (isinstance(value, string_types) or
|
||||
(_PY3 and isinstance(value, binary_type))):
|
||||
yield buf + _encoder(value)
|
||||
elif isinstance(value, RawJSON):
|
||||
yield buf + value.encoded_json
|
||||
elif value is None:
|
||||
yield buf + 'null'
|
||||
elif value is True:
|
||||
|
@ -582,6 +600,8 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
|
|||
if (isinstance(value, string_types) or
|
||||
(_PY3 and isinstance(value, binary_type))):
|
||||
yield _encoder(value)
|
||||
elif isinstance(value, RawJSON):
|
||||
yield value.encoded_json
|
||||
elif value is None:
|
||||
yield 'null'
|
||||
elif value is True:
|
||||
|
@ -624,6 +644,8 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
|
|||
if (isinstance(o, string_types) or
|
||||
(_PY3 and isinstance(o, binary_type))):
|
||||
yield _encoder(o)
|
||||
elif isinstance(o, RawJSON):
|
||||
yield o.encoded_json
|
||||
elif o is None:
|
||||
yield 'null'
|
||||
elif o is True:
|
||||
|
|
Loading…
Reference in a new issue