Commit bde323c3 authored by Piotr Ożarowski's avatar Piotr Ożarowski

Import simplejson_3.10.0.orig.tar.gz

parent a236fe4f
Version 3.10.0 released 2016-10-28
* Add RawJSON class to allow a faster path for already encoded JSON.
https://github.com/simplejson/simplejson/pull/143
Version 3.9.0 released 2016-10-21
* Workaround for bad behavior in string subclasses
https://github.com/simplejson/simplejson/issues/144
* Fix warnings flagged by -3
https://github.com/simplejson/simplejson/pull/146
* Update readthedocs documentation links
https://github.com/simplejson/simplejson/pull/137
* Add build status badge to README
https://github.com/simplejson/simplejson/pull/134
Version 3.8.2 released 2016-02-14
* Fix implicit cast compiler warning in _speedups.c
......@@ -318,7 +334,7 @@ Version 2.2.0 released 2011-09-04
* Force unicode linebreak characters to be escaped (U+2028 and U+2029)
http://timelessrepo.com/json-isnt-a-javascript-subset
* Moved documentation from a git submodule to
http://simplejson.readthedocs.org/
https://simplejson.readthedocs.io/
Version 2.1.6 released 2011-05-08
......
Metadata-Version: 1.1
Name: simplejson
Version: 3.8.2
Version: 3.10.0
Summary: Simple, fast, extensible JSON encoder/decoder for Python
Home-page: http://github.com/simplejson/simplejson
Author: Bob Ippolito
Author-email: bob@redivi.com
License: MIT License
Description: simplejson is a simple, fast, complete, correct and extensible
Description: simplejson
----------
.. image:: https://travis-ci.org/simplejson/simplejson.svg?branch=master
:target: https://travis-ci.org/simplejson/simplejson
simplejson is a simple, fast, complete, correct and extensible
JSON <http://json.org> encoder and decoder for Python 2.5+
and Python 3.3+. It is pure Python code with no dependencies,
but includes an optional C extension for a serious speed boost.
The latest documentation for simplejson can be read online here:
http://simplejson.readthedocs.org/
https://simplejson.readthedocs.io/
simplejson is the externally maintained development version of the
json library included with Python 2.6 and Python 3.0, but maintains
......
simplejson
----------
.. image:: https://travis-ci.org/simplejson/simplejson.svg?branch=master
:target: https://travis-ci.org/simplejson/simplejson
simplejson is a simple, fast, complete, correct and extensible
JSON <http://json.org> encoder and decoder for Python 2.5+
and Python 3.3+. It is pure Python code with no dependencies,
but includes an optional C extension for a serious speed boost.
The latest documentation for simplejson can be read online here:
http://simplejson.readthedocs.org/
https://simplejson.readthedocs.io/
simplejson is the externally maintained development version of the
json library included with Python 2.6 and Python 3.0, but maintains
......
......@@ -36,15 +36,15 @@ master_doc = 'index'
# General substitutions.
project = 'simplejson'
copyright = '2015, Bob Ippolito'
copyright = '2016, Bob Ippolito'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
version = '3.8'
version = '3.10'
# The full version, including alpha/beta/rc tags.
release = '3.8.2'
release = '3.10.0'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
......
......@@ -3,9 +3,13 @@ try:
except ImportError:
from urllib import urlopen
import glob
import io
import json
import os
import re
import subprocess
import sys
def get_json(url):
......@@ -36,12 +40,41 @@ def download_github_artifacts():
release = get_json(
'https://api.github.com/repos/simplejson/simplejson/releases/latest')
for asset in release['assets']:
download_file(asset['url'], 'dist/{name}'.format(**asset))
download_file(asset['browser_download_url'], 'dist/{name}'.format(**asset))
def get_version():
return subprocess.check_output([sys.executable, 'setup.py', '--version']).strip()
def artifact_matcher(version):
return re.compile('^simplejson-{}.*\\.(exe|whl)$'.format(re.escape(version)))
def sign_artifacts(version):
artifacts = set(os.listdir('dist'))
pattern = artifact_matcher(version)
for fn in artifacts:
if pattern.search(fn) and '{}.asc'.format(fn) not in artifacts:
sign_artifact(os.path.join('dist', fn))
def sign_artifact(path):
print(' '.join(['gpg', '--detach-sign', '-a', path]))
subprocess.check_call(['gpg', '--detach-sign', '-a', path])
def upload_artifacts(version):
artifacts = set(os.listdir('dist'))
pattern = artifact_matcher(version)
args = ['twine', 'upload']
for fn in artifacts:
if pattern.search(fn):
filename = os.path.join('dist', fn)
args.extend([filename, filename + '.asc'])
subprocess.check_call(args)
def main():
download_appveyor_artifacts()
download_github_artifacts()
version = get_version()
sign_artifacts(version)
upload_artifacts(version)
if __name__ == '__main__':
......
......@@ -11,7 +11,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
IS_PYPY = hasattr(sys, 'pypy_translation_info')
VERSION = '3.8.2'
VERSION = '3.10.0'
DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
with open('README.rst', 'r') as f:
......
Metadata-Version: 1.1
Name: simplejson
Version: 3.8.2
Version: 3.10.0
Summary: Simple, fast, extensible JSON encoder/decoder for Python
Home-page: http://github.com/simplejson/simplejson
Author: Bob Ippolito
Author-email: bob@redivi.com
License: MIT License
Description: simplejson is a simple, fast, complete, correct and extensible
Description: simplejson
----------
.. image:: https://travis-ci.org/simplejson/simplejson.svg?branch=master
:target: https://travis-ci.org/simplejson/simplejson
simplejson is a simple, fast, complete, correct and extensible
JSON <http://json.org> encoder and decoder for Python 2.5+
and Python 3.3+. It is pure Python code with no dependencies,
but includes an optional C extension for a serious speed boost.
The latest documentation for simplejson can be read online here:
http://simplejson.readthedocs.org/
https://simplejson.readthedocs.io/
simplejson is the externally maintained development version of the
json library included with Python 2.6 and Python 3.0, but maintains
......
......@@ -40,10 +40,12 @@ simplejson/tests/test_namedtuple.py
simplejson/tests/test_pass1.py
simplejson/tests/test_pass2.py
simplejson/tests/test_pass3.py
simplejson/tests/test_raw_json.py
simplejson/tests/test_recursion.py
simplejson/tests/test_scanstring.py
simplejson/tests/test_separators.py
simplejson/tests/test_speedups.py
simplejson/tests/test_str_subclass.py
simplejson/tests/test_subclass.py
simplejson/tests/test_tool.py
simplejson/tests/test_tuple.py
......
......@@ -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.2'
__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)
{
......@@ -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:
......
......@@ -57,6 +57,7 @@ def all_tests_suite():
'simplejson.tests.test_scanstring',
'simplejson.tests.test_separators',
'simplejson.tests.test_speedups',
'simplejson.tests.test_str_subclass',
'simplejson.tests.test_unicode',
'simplejson.tests.test_decimal',
'simplejson.tests.test_tuple',
......@@ -64,6 +65,7 @@ def all_tests_suite():
'simplejson.tests.test_tool',
'simplejson.tests.test_for_json',
'simplejson.tests.test_subclass',
'simplejson.tests.test_raw_json',
]))
suite = get_suite()
import simplejson
......
import unittest
import simplejson as json
dct1 = {
'key1': 'value1'
}
dct2 = {
'key2': 'value2',
'd1': dct1
}
dct3 = {
'key2': 'value2',
'd1': json.dumps(dct1)
}
dct4 = {
'key2': 'value2',
'd1': json.RawJSON(json.dumps(dct1))
}
class TestRawJson(unittest.TestCase):
def test_normal_str(self):
self.assertNotEqual(json.dumps(dct2), json.dumps(dct3))
def test_raw_json_str(self):
self.assertEqual(json.dumps(dct2), json.dumps(dct4))
self.assertEqual(dct2, json.loads(json.dumps(dct4)))
def test_list(self):
self.assertEqual(
json.dumps([dct2]),
json.dumps([json.RawJSON(json.dumps(dct2))]))
self.assertEqual(
[dct2],
json.loads(json.dumps([json.RawJSON(json.dumps(dct2))])))
def test_direct(self):
self.assertEqual(
json.dumps(dct2),
json.dumps(json.RawJSON(json.dumps(dct2))))
self.assertEqual(
dct2,
json.loads(json.dumps(json.RawJSON(json.dumps(dct2)))))
from unittest import TestCase
import simplejson
from simplejson.compat import text_type, u
# Tests for issue demonstrated in https://github.com/simplejson/simplejson/issues/144
class WonkyTextSubclass(text_type):
def __getslice__(self, start, end):
return self.__class__('not what you wanted!')
class TestStrSubclass(TestCase):
def test_dump_load(self):
for s in ['', '"hello"', 'text', u('\u005c')]:
self.assertEqual(
s,
simplejson.loads(simplejson.dumps(WonkyTextSubclass(s))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment