Hello community, here is the log from the commit of package python-simplejson for openSUSE:Factory checked in at 2017-08-14 12:37:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-simplejson (Old) and /work/SRC/openSUSE:Factory/.python-simplejson.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-simplejson" Mon Aug 14 12:37:10 2017 rev:35 rq:515233 version:3.11.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-simplejson/python-simplejson.changes 2017-04-19 18:01:32.600624292 +0200 +++ /work/SRC/openSUSE:Factory/.python-simplejson.new/python-simplejson.changes 2017-08-14 12:37:14.091467671 +0200 @@ -1,0 +2,16 @@ +Tue Aug 8 18:50:31 UTC 2017 - tbecht...@suse.com + +- update to 3.11.1: + * Fix issue with item_sort_key when speedups are available, and add + auto-discovery to test suites to prevent similar regressions + * docstring fix in JSONEncoder + * Call PyObject_IsTrue() only once for the strict argument of scann er + * Fix a crash with unencodable encoding in the encoder + * Remove unused imports + * Remove remnants of Python 2.4 support + * Fix argument checking errors in _speedups.c + * Remove the `__init__` methods in extension classes + * Fix typo in the doc for loads + * Add Python 3.6 to testing matrix and PyPI metadata + +------------------------------------------------------------------- Old: ---- simplejson-3.10.0.tar.gz New: ---- simplejson-3.11.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-simplejson.spec ++++++ --- /var/tmp/diff_new_pack.I4De7W/_old 2017-08-14 12:37:15.531265489 +0200 +++ /var/tmp/diff_new_pack.I4De7W/_new 2017-08-14 12:37:15.535264927 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-simplejson -Version: 3.10.0 +Version: 3.11.1 Release: 0 Summary: Simple, fast, extensible JSON encoder/decoder for Python License: MIT or AFL-2.1 ++++++ simplejson-3.10.0.tar.gz -> simplejson-3.11.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/CHANGES.txt new/simplejson-3.11.1/CHANGES.txt --- old/simplejson-3.10.0/CHANGES.txt 2016-10-28 11:45:34.000000000 +0200 +++ new/simplejson-3.11.1/CHANGES.txt 2017-06-19 22:11:11.000000000 +0200 @@ -1,3 +1,31 @@ +Version 3.11.1 released 2017-06-19 + +* Fix issue with item_sort_key when speedups are available, and add + auto-discovery to test suites to prevent similar regressions + https://github.com/simplejson/simplejson/issues/173 + +Version 3.11.0 released 2017-06-18 + +* docstring fix in JSONEncoder + https://github.com/simplejson/simplejson/pull/172 +* Call PyObject_IsTrue() only once for the strict argument of scanner + https://github.com/simplejson/simplejson/pull/170 +* Fix a crash with unencodable encoding in the encoder + https://github.com/simplejson/simplejson/pull/171 +* Remove unused imports + https://github.com/simplejson/simplejson/pull/162 +* Remove remnants of Python 2.4 support + https://github.com/simplejson/simplejson/pull/168 +* Fix argument checking errors in _speedups.c + https://github.com/simplejson/simplejson/pull/169 +* Remove the `__init__` methods in extension classes + https://github.com/simplejson/simplejson/pull/166 +* Fix typo in the doc for loads + https://github.com/simplejson/simplejson/issues/161 +* Add Python 3.6 to testing matrix and PyPI metadata + https://github.com/simplejson/simplejson/pull/153 + https://github.com/simplejson/simplejson/pull/152 + Version 3.10.0 released 2016-10-28 * Add RawJSON class to allow a faster path for already encoded JSON. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/PKG-INFO new/simplejson-3.11.1/PKG-INFO --- old/simplejson-3.10.0/PKG-INFO 2016-10-28 12:01:25.000000000 +0200 +++ new/simplejson-3.11.1/PKG-INFO 2017-06-19 22:11:30.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: simplejson -Version: 3.10.0 +Version: 3.11.1 Summary: Simple, fast, extensible JSON encoder/decoder for Python Home-page: http://github.com/simplejson/simplejson Author: Bob Ippolito @@ -55,6 +55,8 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/conf.py new/simplejson-3.11.1/conf.py --- old/simplejson-3.10.0/conf.py 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/conf.py 2017-06-19 22:11:11.000000000 +0200 @@ -36,15 +36,15 @@ # General substitutions. project = 'simplejson' -copyright = '2016, Bob Ippolito' +copyright = '2017, 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.10' +version = '3.11' # The full version, including alpha/beta/rc tags. -release = '3.10.0' +release = '3.11.1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/index.rst new/simplejson-3.11.1/index.rst --- old/simplejson-3.10.0/index.rst 2015-07-18 23:46:40.000000000 +0200 +++ new/simplejson-3.11.1/index.rst 2017-06-19 20:13:33.000000000 +0200 @@ -407,7 +407,7 @@ only one JSON document, it is recommended to use :func:`loads`. -.. function:: loads(fp, encoding='utf-8', cls=None, object_hook=None, \ +.. function:: loads(s, encoding='utf-8', cls=None, object_hook=None, \ parse_float=None, parse_int=None, \ parse_constant=None, object_pairs_hook=None, \ use_decimal=None, **kw) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/scripts/artifacts.py new/simplejson-3.11.1/scripts/artifacts.py --- old/simplejson-3.10.0/scripts/artifacts.py 2016-10-22 01:59:09.000000000 +0200 +++ new/simplejson-3.11.1/scripts/artifacts.py 2017-06-19 20:13:33.000000000 +0200 @@ -3,8 +3,6 @@ except ImportError: from urllib import urlopen -import glob -import io import json import os import re diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/scripts/make_docs.py new/simplejson-3.11.1/scripts/make_docs.py --- old/simplejson-3.10.0/scripts/make_docs.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.11.1/scripts/make_docs.py 2017-06-19 20:13:33.000000000 +0200 @@ -1,7 +1,6 @@ #!/usr/bin/env python import os import subprocess -import shutil SPHINX_BUILD = 'sphinx-build' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/setup.py new/simplejson-3.11.1/setup.py --- old/simplejson-3.10.0/setup.py 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/setup.py 2017-06-19 22:11:11.000000000 +0200 @@ -11,7 +11,7 @@ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.10.0' +VERSION = '3.11.1' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: @@ -31,6 +31,8 @@ Programming Language :: Python :: 3 Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 +Programming Language :: Python :: 3.5 +Programming Language :: Python :: 3.6 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/__init__.py new/simplejson-3.11.1/simplejson/__init__.py --- old/simplejson-3.10.0/simplejson/__init__.py 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/__init__.py 2017-06-19 22:11:11.000000000 +0200 @@ -97,7 +97,7 @@ Expecting property name: line 1 column 3 (char 2) """ from __future__ import absolute_import -__version__ = '3.10.0' +__version__ = '3.11.1' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/_speedups.c new/simplejson-3.11.1/simplejson/_speedups.c --- old/simplejson-3.10.0/simplejson/_speedups.c 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/_speedups.c 2017-06-19 22:11:11.000000000 +0200 @@ -68,19 +68,6 @@ #endif #endif /* PY_VERSION_HEX < 0x02060000 */ -#if PY_VERSION_HEX < 0x02050000 -#if !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#define PyInt_FromSsize_t PyInt_FromLong -#define PyInt_AsSsize_t PyInt_AsLong -#endif -#if !defined(Py_IS_FINITE) -#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) -#endif -#endif /* PY_VERSION_HEX < 0x02050000 */ - #ifdef __GNUC__ #define UNUSED __attribute__((__unused__)) #else @@ -129,7 +116,8 @@ typedef struct _PyScannerObject { PyObject_HEAD PyObject *encoding; - PyObject *strict; + PyObject *strict_bool; + int strict; PyObject *object_hook; PyObject *pairs_hook; PyObject *parse_float; @@ -140,7 +128,7 @@ static PyMemberDef scanner_members[] = { {"encoding", T_OBJECT, offsetof(PyScannerObject, encoding), READONLY, "encoding"}, - {"strict", T_OBJECT, offsetof(PyScannerObject, strict), READONLY, "strict"}, + {"strict", T_OBJECT, offsetof(PyScannerObject, strict_bool), READONLY, "strict"}, {"object_hook", T_OBJECT, offsetof(PyScannerObject, object_hook), READONLY, "object_hook"}, {"object_pairs_hook", T_OBJECT, offsetof(PyScannerObject, pairs_hook), READONLY, "object_pairs_hook"}, {"parse_float", T_OBJECT, offsetof(PyScannerObject, parse_float), READONLY, "parse_float"}, @@ -231,16 +219,12 @@ _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx); static PyObject * scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds); -static int -scanner_init(PyObject *self, PyObject *args, PyObject *kwds); static void scanner_dealloc(PyObject *self); static int scanner_clear(PyObject *self); static PyObject * encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds); -static int -encoder_init(PyObject *self, PyObject *args, PyObject *kwds); static void encoder_dealloc(PyObject *self); static int @@ -659,10 +643,13 @@ } else if (PyString_Check(key)) { #if PY_MAJOR_VERSION >= 3 + const char *encoding = JSON_ASCII_AS_STRING(s->encoding); + if (encoding == NULL) + return NULL; return PyUnicode_Decode( PyString_AS_STRING(key), PyString_GET_SIZE(key), - JSON_ASCII_AS_STRING(s->encoding), + encoding, NULL); #else /* PY_MAJOR_VERSION >= 3 */ Py_INCREF(key); @@ -1397,7 +1384,7 @@ assert(PyScanner_Check(self)); s = (PyScannerObject *)self; Py_VISIT(s->encoding); - Py_VISIT(s->strict); + Py_VISIT(s->strict_bool); Py_VISIT(s->object_hook); Py_VISIT(s->pairs_hook); Py_VISIT(s->parse_float); @@ -1414,7 +1401,7 @@ assert(PyScanner_Check(self)); s = (PyScannerObject *)self; Py_CLEAR(s->encoding); - Py_CLEAR(s->strict); + Py_CLEAR(s->strict_bool); Py_CLEAR(s->object_hook); Py_CLEAR(s->pairs_hook); Py_CLEAR(s->parse_float); @@ -1444,7 +1431,6 @@ PyObject *key = NULL; PyObject *val = NULL; char *encoding = JSON_ASCII_AS_STRING(s->encoding); - int strict = PyObject_IsTrue(s->strict); int has_pairs_hook = (s->pairs_hook != Py_None); int did_parse = 0; Py_ssize_t next_idx; @@ -1474,7 +1460,7 @@ raise_errmsg(ERR_OBJECT_PROPERTY, pystr, idx); goto bail; } - key = scanstring_str(pystr, idx + 1, encoding, strict, &next_idx); + key = scanstring_str(pystr, idx + 1, encoding, s->strict, &next_idx); if (key == NULL) goto bail; memokey = PyDict_GetItem(s->memo, key); @@ -1605,7 +1591,6 @@ PyObject *item; PyObject *key = NULL; PyObject *val = NULL; - int strict = PyObject_IsTrue(s->strict); int has_pairs_hook = (s->pairs_hook != Py_None); int did_parse = 0; Py_ssize_t next_idx; @@ -1636,7 +1621,7 @@ raise_errmsg(ERR_OBJECT_PROPERTY, pystr, idx); goto bail; } - key = scanstring_unicode(pystr, idx + 1, strict, &next_idx); + key = scanstring_unicode(pystr, idx + 1, s->strict, &next_idx); if (key == NULL) goto bail; memokey = PyDict_GetItem(s->memo, key); @@ -2180,7 +2165,7 @@ /* string */ rval = scanstring_str(pystr, idx + 1, JSON_ASCII_AS_STRING(s->encoding), - PyObject_IsTrue(s->strict), + s->strict, next_idx_ptr); break; case '{': @@ -2287,7 +2272,7 @@ case '"': /* string */ rval = scanstring_unicode(pystr, idx + 1, - PyObject_IsTrue(s->strict), + s->strict, next_idx_ptr); break; case '{': @@ -2430,23 +2415,6 @@ } static PyObject * -scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyScannerObject *s; - s = (PyScannerObject *)type->tp_alloc(type, 0); - if (s != NULL) { - s->encoding = NULL; - s->strict = NULL; - s->object_hook = NULL; - s->pairs_hook = NULL; - s->parse_float = NULL; - s->parse_int = NULL; - s->parse_constant = NULL; - } - return (PyObject *)s; -} - -static PyObject * JSON_ParseEncoding(PyObject *encoding) { if (encoding == NULL) @@ -2465,8 +2433,8 @@ return NULL; } -static int -scanner_init(PyObject *self, PyObject *args, PyObject *kwds) +static PyObject * +scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { /* Initialize Scanner object */ PyObject *ctx; @@ -2474,11 +2442,12 @@ PyScannerObject *s; PyObject *encoding; - assert(PyScanner_Check(self)); - s = (PyScannerObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:make_scanner", kwlist, &ctx)) - return -1; + return NULL; + + s = (PyScannerObject *)type->tp_alloc(type, 0); + if (s == NULL) + return NULL; if (s->memo == NULL) { s->memo = PyDict_New(); @@ -2494,8 +2463,11 @@ goto bail; /* All of these will fail "gracefully" so we don't need to verify them */ - s->strict = PyObject_GetAttrString(ctx, "strict"); - if (s->strict == NULL) + s->strict_bool = PyObject_GetAttrString(ctx, "strict"); + if (s->strict_bool == NULL) + goto bail; + s->strict = PyObject_IsTrue(s->strict_bool); + if (s->strict < 0) goto bail; s->object_hook = PyObject_GetAttrString(ctx, "object_hook"); if (s->object_hook == NULL) @@ -2513,17 +2485,11 @@ if (s->parse_constant == NULL) goto bail; - return 0; + return (PyObject *)s; bail: - Py_CLEAR(s->encoding); - Py_CLEAR(s->strict); - Py_CLEAR(s->object_hook); - Py_CLEAR(s->pairs_hook); - Py_CLEAR(s->parse_float); - Py_CLEAR(s->parse_int); - Py_CLEAR(s->parse_constant); - return -1; + Py_DECREF(s); + return NULL; } PyDoc_STRVAR(scanner_doc, "JSON scanner object"); @@ -2565,7 +2531,7 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - scanner_init, /* tp_init */ + 0, /* tp_init */ 0,/* PyType_GenericAlloc, */ /* tp_alloc */ scanner_new, /* tp_new */ 0,/* PyObject_GC_Del, */ /* tp_free */ @@ -2574,30 +2540,6 @@ static PyObject * encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyEncoderObject *s; - s = (PyEncoderObject *)type->tp_alloc(type, 0); - if (s != NULL) { - s->markers = NULL; - s->defaultfn = NULL; - s->encoder = NULL; - s->encoding = NULL; - s->indent = NULL; - s->key_separator = NULL; - s->item_separator = NULL; - s->key_memo = NULL; - s->sort_keys = NULL; - s->item_sort_key = NULL; - s->item_sort_kw = NULL; - s->Decimal = NULL; - s->max_long_size = NULL; - s->min_long_size = NULL; - } - return (PyObject *)s; -} - -static int -encoder_init(PyObject *self, PyObject *args, PyObject *kwds) -{ static char *kwlist[] = { "markers", "default", @@ -2627,9 +2569,7 @@ PyObject *use_decimal, *namedtuple_as_object, *tuple_as_array, *iterable_as_array; PyObject *int_as_string_bitcount, *item_sort_key, *encoding, *for_json; PyObject *ignore_nan, *Decimal; - - assert(PyEncoder_Check(self)); - s = (PyEncoderObject *)self; + int is_true; if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOOOOOOOOOOOOO:make_encoder", kwlist, &markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator, @@ -2637,7 +2577,11 @@ &namedtuple_as_object, &tuple_as_array, &int_as_string_bitcount, &item_sort_key, &encoding, &for_json, &ignore_nan, &Decimal, &iterable_as_array)) - return -1; + return NULL; + + s = (PyEncoderObject *)type->tp_alloc(type, 0); + if (s == NULL) + return NULL; Py_INCREF(markers); s->markers = markers; @@ -2647,7 +2591,9 @@ s->encoder = encoder; s->encoding = JSON_ParseEncoding(encoding); if (s->encoding == NULL) - return -1; + goto bail; + if (JSON_ASCII_AS_STRING(s->encoding) == NULL) + goto bail; Py_INCREF(indent); s->indent = indent; Py_INCREF(key_separator); @@ -2657,31 +2603,46 @@ Py_INCREF(skipkeys); s->skipkeys_bool = skipkeys; s->skipkeys = PyObject_IsTrue(skipkeys); + if (s->skipkeys < 0) + goto bail; Py_INCREF(key_memo); s->key_memo = key_memo; s->fast_encode = (PyCFunction_Check(s->encoder) && PyCFunction_GetFunction(s->encoder) == (PyCFunction)py_encode_basestring_ascii); - s->allow_or_ignore_nan = ( - (PyObject_IsTrue(ignore_nan) ? JSON_IGNORE_NAN : 0) | - (PyObject_IsTrue(allow_nan) ? JSON_ALLOW_NAN : 0)); + is_true = PyObject_IsTrue(ignore_nan); + if (is_true < 0) + goto bail; + s->allow_or_ignore_nan = is_true ? JSON_IGNORE_NAN : 0; + is_true = PyObject_IsTrue(allow_nan); + if (is_true < 0) + goto bail; + s->allow_or_ignore_nan |= is_true ? JSON_ALLOW_NAN : 0; s->use_decimal = PyObject_IsTrue(use_decimal); + if (s->use_decimal < 0) + goto bail; s->namedtuple_as_object = PyObject_IsTrue(namedtuple_as_object); + if (s->namedtuple_as_object < 0) + goto bail; s->tuple_as_array = PyObject_IsTrue(tuple_as_array); + if (s->tuple_as_array < 0) + goto bail; s->iterable_as_array = PyObject_IsTrue(iterable_as_array); + if (s->iterable_as_array < 0) + goto bail; 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 < (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); + static const unsigned long long_long_bitsize = SIZEOF_LONG_LONG * 8; + long int_as_string_bitcount_val = PyLong_AsLong(int_as_string_bitcount); + if (int_as_string_bitcount_val > 0 && int_as_string_bitcount_val < (long)long_long_bitsize) { + s->max_long_size = PyLong_FromUnsignedLongLong(1ULL << (int)int_as_string_bitcount_val); + s->min_long_size = PyLong_FromLongLong(-1LL << (int)int_as_string_bitcount_val); if (s->min_long_size == NULL || s->max_long_size == NULL) { - return -1; + goto bail; } } else { PyErr_Format(PyExc_TypeError, - "int_as_string_bitcount (%d) must be greater than 0 and less than the number of bits of a `long long` type (%u bits)", + "int_as_string_bitcount (%ld) must be greater than 0 and less than the number of bits of a `long long` type (%lu bits)", int_as_string_bitcount_val, long_long_bitsize); - return -1; + goto bail; } } else if (int_as_string_bitcount == Py_None) { @@ -2692,26 +2653,31 @@ } else { PyErr_SetString(PyExc_TypeError, "int_as_string_bitcount must be None or an integer"); - return -1; + goto bail; } if (item_sort_key != Py_None) { if (!PyCallable_Check(item_sort_key)) { PyErr_SetString(PyExc_TypeError, "item_sort_key must be None or callable"); - return -1; + goto bail; } } - else if (PyObject_IsTrue(sort_keys)) { - static PyObject *itemgetter0 = NULL; - if (!itemgetter0) { - PyObject *operator = PyImport_ImportModule("operator"); - if (!operator) - return -1; - itemgetter0 = PyObject_CallMethod(operator, "itemgetter", "i", 0); - Py_DECREF(operator); + else { + is_true = PyObject_IsTrue(sort_keys); + if (is_true < 0) + goto bail; + if (is_true) { + static PyObject *itemgetter0 = NULL; + if (!itemgetter0) { + PyObject *operator = PyImport_ImportModule("operator"); + if (!operator) + goto bail; + itemgetter0 = PyObject_CallMethod(operator, "itemgetter", "i", 0); + Py_DECREF(operator); + } + item_sort_key = itemgetter0; + if (!item_sort_key) + goto bail; } - item_sort_key = itemgetter0; - if (!item_sort_key) - return -1; } if (item_sort_key == Py_None) { Py_INCREF(Py_None); @@ -2720,9 +2686,9 @@ else { s->item_sort_kw = PyDict_New(); if (s->item_sort_kw == NULL) - return -1; + goto bail; if (PyDict_SetItemString(s->item_sort_kw, "key", item_sort_key)) - return -1; + goto bail; } Py_INCREF(sort_keys); s->sort_keys = sort_keys; @@ -2731,8 +2697,14 @@ Py_INCREF(Decimal); s->Decimal = Decimal; s->for_json = PyObject_IsTrue(for_json); + if (s->for_json < 0) + goto bail; - return 0; + return (PyObject *)s; + +bail: + Py_DECREF(s); + return NULL; } static PyObject * @@ -3342,7 +3314,7 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - encoder_init, /* tp_init */ + 0, /* tp_init */ 0, /* tp_alloc */ encoder_new, /* tp_new */ 0, /* tp_free */ @@ -3381,10 +3353,8 @@ moduleinit(void) { PyObject *m; - PyScannerType.tp_new = PyType_GenericNew; if (PyType_Ready(&PyScannerType) < 0) return NULL; - PyEncoderType.tp_new = PyType_GenericNew; if (PyType_Ready(&PyEncoderType) < 0) return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/decoder.py new/simplejson-3.11.1/simplejson/decoder.py --- old/simplejson-3.10.0/simplejson/decoder.py 2016-10-21 04:58:09.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/decoder.py 2017-06-19 20:13:33.000000000 +0200 @@ -4,7 +4,7 @@ import re import sys import struct -from .compat import b, u, text_type, binary_type, PY3, unichr +from .compat import u, text_type, binary_type, PY3, unichr from .scanner import make_scanner, JSONDecodeError def _import_c_scanstring(): @@ -24,11 +24,7 @@ def _floatconstants(): 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) + nan, inf = struct.unpack('>dd', _BYTES) else: nan = float('nan') inf = float('inf') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/encoder.py new/simplejson-3.11.1/simplejson/encoder.py --- old/simplejson-3.10.0/simplejson/encoder.py 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/encoder.py 2017-06-19 20:13:33.000000000 +0200 @@ -185,7 +185,7 @@ transformed into unicode using that encoding prior to JSON-encoding. The default is UTF-8. - If use_decimal is true (not the default), ``decimal.Decimal`` will + If use_decimal is true (default: ``True``), ``decimal.Decimal`` will be supported directly by the encoder. For the inverse, decode JSON with ``parse_float=decimal.Decimal``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/ordered_dict.py new/simplejson-3.11.1/simplejson/ordered_dict.py --- old/simplejson-3.10.0/simplejson/ordered_dict.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/ordered_dict.py 2017-06-19 20:13:33.000000000 +0200 @@ -5,17 +5,6 @@ """ from UserDict import DictMixin -# Modified from original to support Python 2.4, see -# http://code.google.com/p/simplejson/issues/detail?id=53 -try: - all -except NameError: - def all(seq): - for elem in seq: - if not elem: - return False - return True - class OrderedDict(dict, DictMixin): def __init__(self, *args, **kwds): @@ -63,12 +52,7 @@ def popitem(self, last=True): if not self: raise KeyError('dictionary is empty') - # Modified from original to support Python 2.4, see - # http://code.google.com/p/simplejson/issues/detail?id=53 - if last: - key = reversed(self).next() - else: - key = iter(self).next() + key = reversed(self).next() if last else iter(self).next() value = self.pop(key) return key, value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/tests/__init__.py new/simplejson-3.11.1/simplejson/tests/__init__.py --- old/simplejson-3.10.0/simplejson/tests/__init__.py 2016-10-28 11:25:45.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/tests/__init__.py 2017-06-19 22:11:11.000000000 +0200 @@ -2,6 +2,7 @@ import unittest import doctest import sys +import os class NoExtensionTestSuite(unittest.TestSuite): @@ -35,38 +36,13 @@ def all_tests_suite(): def get_suite(): + suite_names = [ + 'simplejson.tests.%s' % (os.path.splitext(f)[0],) + for f in os.listdir(os.path.dirname(__file__)) + if f.startswith('test_') and f.endswith('.py') + ] return additional_tests( - unittest.TestLoader().loadTestsFromNames([ - 'simplejson.tests.test_bitsize_int_as_string', - 'simplejson.tests.test_bigint_as_string', - 'simplejson.tests.test_check_circular', - 'simplejson.tests.test_decode', - 'simplejson.tests.test_default', - 'simplejson.tests.test_dump', - 'simplejson.tests.test_encode_basestring_ascii', - 'simplejson.tests.test_encode_for_html', - 'simplejson.tests.test_errors', - 'simplejson.tests.test_fail', - 'simplejson.tests.test_float', - 'simplejson.tests.test_indent', - 'simplejson.tests.test_iterable', - 'simplejson.tests.test_pass1', - 'simplejson.tests.test_pass2', - 'simplejson.tests.test_pass3', - 'simplejson.tests.test_recursion', - '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', - 'simplejson.tests.test_namedtuple', - 'simplejson.tests.test_tool', - 'simplejson.tests.test_for_json', - 'simplejson.tests.test_subclass', - 'simplejson.tests.test_raw_json', - ])) + unittest.TestLoader().loadTestsFromNames(suite_names)) suite = get_suite() import simplejson if simplejson._import_c_make_encoder() is None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/tests/test_item_sort_key.py new/simplejson-3.11.1/simplejson/tests/test_item_sort_key.py --- old/simplejson-3.10.0/simplejson/tests/test_item_sort_key.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/tests/test_item_sort_key.py 2017-06-19 22:11:11.000000000 +0200 @@ -18,3 +18,10 @@ self.assertEqual( '{"a": 1, "Array": [1, 5, 6, 9], "c": 5, "crate": "dog", "Jack": "jill", "pick": "axe", "tuple": [83, 12, 3], "zeak": "oh"}', json.dumps(a, item_sort_key=lambda kv: kv[0].lower())) + + def test_item_sort_key_value(self): + # https://github.com/simplejson/simplejson/issues/173 + a = {'a': 1, 'b': 0} + self.assertEqual( + '{"b": 0, "a": 1}', + json.dumps(a, item_sort_key=lambda kv: kv[1])) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson/tests/test_speedups.py new/simplejson-3.11.1/simplejson/tests/test_speedups.py --- old/simplejson-3.10.0/simplejson/tests/test_speedups.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.11.1/simplejson/tests/test_speedups.py 2017-06-19 20:13:33.000000000 +0200 @@ -1,8 +1,12 @@ +from __future__ import with_statement + import sys import unittest from unittest import TestCase -from simplejson import encoder, scanner +import simplejson +from simplejson import encoder, decoder, scanner +from simplejson.compat import PY3, long_type, b def has_speedups(): @@ -22,12 +26,29 @@ return wrapper +class BadBool: + def __bool__(self): + 1/0 + __nonzero__ = __bool__ + + class TestDecode(TestCase): @skip_if_speedups_missing def test_make_scanner(self): self.assertRaises(AttributeError, scanner.c_make_scanner, 1) @skip_if_speedups_missing + def test_bad_bool_args(self): + def test(value): + decoder.JSONDecoder(strict=BadBool()).decode(value) + self.assertRaises(ZeroDivisionError, test, '""') + self.assertRaises(ZeroDivisionError, test, '{}') + if not PY3: + self.assertRaises(ZeroDivisionError, test, u'""') + self.assertRaises(ZeroDivisionError, test, u'{}') + +class TestEncode(TestCase): + @skip_if_speedups_missing def test_make_encoder(self): self.assertRaises( TypeError, @@ -37,3 +58,33 @@ "\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75"), None ) + + @skip_if_speedups_missing + def test_bad_bool_args(self): + def test(name): + encoder.JSONEncoder(**{name: BadBool()}).encode({}) + self.assertRaises(ZeroDivisionError, test, 'skipkeys') + self.assertRaises(ZeroDivisionError, test, 'ensure_ascii') + self.assertRaises(ZeroDivisionError, test, 'check_circular') + self.assertRaises(ZeroDivisionError, test, 'allow_nan') + self.assertRaises(ZeroDivisionError, test, 'sort_keys') + self.assertRaises(ZeroDivisionError, test, 'use_decimal') + self.assertRaises(ZeroDivisionError, test, 'namedtuple_as_object') + self.assertRaises(ZeroDivisionError, test, 'tuple_as_array') + self.assertRaises(ZeroDivisionError, test, 'bigint_as_string') + self.assertRaises(ZeroDivisionError, test, 'for_json') + self.assertRaises(ZeroDivisionError, test, 'ignore_nan') + self.assertRaises(ZeroDivisionError, test, 'iterable_as_array') + + @skip_if_speedups_missing + def test_int_as_string_bitcount_overflow(self): + long_count = long_type(2)**32+31 + def test(): + encoder.JSONEncoder(int_as_string_bitcount=long_count).encode(0) + self.assertRaises((TypeError, OverflowError), test) + + if PY3: + @skip_if_speedups_missing + def test_bad_encoding(self): + with self.assertRaises(UnicodeEncodeError): + encoder.JSONEncoder(encoding='\udcff').encode({b('key'): 123}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.10.0/simplejson.egg-info/PKG-INFO new/simplejson-3.11.1/simplejson.egg-info/PKG-INFO --- old/simplejson-3.10.0/simplejson.egg-info/PKG-INFO 2016-10-28 12:01:25.000000000 +0200 +++ new/simplejson-3.11.1/simplejson.egg-info/PKG-INFO 2017-06-19 22:11:29.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: simplejson -Version: 3.10.0 +Version: 3.11.1 Summary: Simple, fast, extensible JSON encoder/decoder for Python Home-page: http://github.com/simplejson/simplejson Author: Bob Ippolito @@ -55,6 +55,8 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries :: Python Modules