Hello community, here is the log from the commit of package python3-simplejson for openSUSE:Factory checked in at 2015-06-01 09:55:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-simplejson (Old) and /work/SRC/openSUSE:Factory/.python3-simplejson.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python3-simplejson" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-simplejson/python3-simplejson.changes 2014-12-01 14:01:14.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python3-simplejson.new/python3-simplejson.changes 2015-06-01 09:55:19.000000000 +0200 @@ -1,0 +2,20 @@ +Sat May 30 17:54:55 UTC 2015 - arun@gmx.de + +- specfile: + * update copyright year + +- update to version 3.7.2: + * Do not cache Decimal class in encoder, only reference the decimal + module. This may make reload work in more common scenarios. + +- changes from Version 3.7.1: + * Fix compilation with MSVC + https://github.com/simplejson/simplejson/pull/119 + +- changes from Version 3.7.0: + * simplejson no longer trusts custom str/repr methods for int, long, + float subclasses. These instances are now formatted as if they + were exact instances of those types. + https://github.com/simplejson/simplejson/issues/118 + +------------------------------------------------------------------- Old: ---- simplejson-3.6.5.tar.gz New: ---- simplejson-3.7.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-simplejson.spec ++++++ --- /var/tmp/diff_new_pack.aLx473/_old 2015-06-01 09:55:20.000000000 +0200 +++ /var/tmp/diff_new_pack.aLx473/_new 2015-06-01 09:55:20.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python3-simplejson # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python3-simplejson -Version: 3.6.5 +Version: 3.7.2 Release: 0 Url: http://github.com/simplejson/simplejson Summary: Simple, fast, extensible JSON encoder/decoder for Python ++++++ simplejson-3.6.5.tar.gz -> simplejson-3.7.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/CHANGES.txt new/simplejson-3.7.2/CHANGES.txt --- old/simplejson-3.6.5/CHANGES.txt 2014-10-24 17:13:39.000000000 +0200 +++ new/simplejson-3.7.2/CHANGES.txt 2015-05-22 18:26:24.000000000 +0200 @@ -1,3 +1,20 @@ +Version 3.7.2 released 2015-05-22 + +* Do not cache Decimal class in encoder, only reference the decimal module. + This may make reload work in more common scenarios. + +Version 3.7.1 released 2015-05-18 + +* Fix compilation with MSVC + https://github.com/simplejson/simplejson/pull/119 + +Version 3.7.0 released 2015-05-18 + +* simplejson no longer trusts custom str/repr methods for int, long, float + subclasses. These instances are now formatted as if they were exact + instances of those types. + https://github.com/simplejson/simplejson/issues/118 + Version 3.6.5 released 2014-10-24 * Importing bug fix for reference leak when an error occurs during diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/PKG-INFO new/simplejson-3.7.2/PKG-INFO --- old/simplejson-3.6.5/PKG-INFO 2014-10-24 17:18:17.000000000 +0200 +++ new/simplejson-3.7.2/PKG-INFO 2015-05-22 18:34:43.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: simplejson -Version: 3.6.5 +Version: 3.7.2 Summary: Simple, fast, extensible JSON encoder/decoder for Python Home-page: http://github.com/simplejson/simplejson Author: Bob Ippolito diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/conf.py new/simplejson-3.7.2/conf.py --- old/simplejson-3.6.5/conf.py 2014-10-24 17:14:03.000000000 +0200 +++ new/simplejson-3.7.2/conf.py 2015-05-22 18:23:16.000000000 +0200 @@ -36,15 +36,15 @@ # General substitutions. project = 'simplejson' -copyright = '2014, Bob Ippolito' +copyright = '2015, 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.6' +version = '3.7' # The full version, including alpha/beta/rc tags. -release = '3.6.5' +release = '3.7.2' # 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.6.5/index.rst new/simplejson-3.7.2/index.rst --- old/simplejson-3.6.5/index.rst 2014-08-18 21:53:31.000000000 +0200 +++ new/simplejson-3.7.2/index.rst 2015-05-18 18:28:42.000000000 +0200 @@ -101,7 +101,7 @@ >>> def encode_complex(obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] - ... raise TypeError(repr(o) + " is not JSON serializable") + ... raise TypeError(repr(obj) + " is not JSON serializable") ... >>> json.dumps(2 + 1j, default=encode_complex) '[2.0, 1.0]' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/setup.py new/simplejson-3.7.2/setup.py --- old/simplejson-3.6.5/setup.py 2014-10-24 17:14:06.000000000 +0200 +++ new/simplejson-3.7.2/setup.py 2015-05-22 18:23:31.000000000 +0200 @@ -11,7 +11,7 @@ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.6.5' +VERSION = '3.7.2' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson/__init__.py new/simplejson-3.7.2/simplejson/__init__.py --- old/simplejson-3.6.5/simplejson/__init__.py 2014-10-24 17:14:00.000000000 +0200 +++ new/simplejson-3.7.2/simplejson/__init__.py 2015-05-22 18:21:54.000000000 +0200 @@ -98,7 +98,7 @@ Expecting property name: line 1 column 3 (char 2) """ from __future__ import absolute_import -__version__ = '3.6.5' +__version__ = '3.7.2' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson/_speedups.c new/simplejson-3.7.2/simplejson/_speedups.c --- old/simplejson-3.6.5/simplejson/_speedups.c 2014-10-24 17:12:40.000000000 +0200 +++ new/simplejson-3.7.2/simplejson/_speedups.c 2015-05-19 04:12:00.000000000 +0200 @@ -10,6 +10,7 @@ #define PyString_AS_STRING PyBytes_AS_STRING #define PyString_FromStringAndSize PyBytes_FromStringAndSize #define PyInt_Check(obj) 0 +#define PyInt_CheckExact(obj) 0 #define JSON_UNICHR Py_UCS4 #define JSON_InternFromString PyUnicode_InternFromString #define JSON_Intern_GET_SIZE PyUnicode_GET_SIZE @@ -660,7 +661,20 @@ return _encoded_const(key); } else if (PyInt_Check(key) || PyLong_Check(key)) { - return PyObject_Str(key); + if (!(PyInt_CheckExact(key) || PyLong_CheckExact(key))) { + /* See #118, do not trust custom str/repr */ + PyObject *res; + PyObject *tmp = PyObject_CallFunctionObjArgs((PyObject *)&PyLong_Type, key, NULL); + if (tmp == NULL) { + return NULL; + } + res = PyObject_Str(tmp); + Py_DECREF(tmp); + return res; + } + else { + return PyObject_Str(key); + } } else if (s->use_decimal && PyObject_TypeCheck(key, (PyTypeObject *)s->Decimal)) { return PyObject_Str(key); @@ -2637,7 +2651,7 @@ s->tuple_as_array = PyObject_IsTrue(tuple_as_array); 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 = PyLong_AsLong(int_as_string_bitcount); + 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) { s->max_long_size = PyLong_FromUnsignedLongLong(1ULL << int_as_string_bitcount_val); s->min_long_size = PyLong_FromLongLong(-1LL << int_as_string_bitcount_val); @@ -2800,7 +2814,20 @@ } } /* Use a better float format here? */ - return PyObject_Repr(obj); + if (PyFloat_CheckExact(obj)) { + return PyObject_Repr(obj); + } + else { + /* See #118, do not trust custom str/repr */ + PyObject *res; + PyObject *tmp = PyObject_CallFunctionObjArgs((PyObject *)&PyFloat_Type, obj, NULL); + if (tmp == NULL) { + return NULL; + } + res = PyObject_Repr(tmp); + Py_DECREF(tmp); + return res; + } } static PyObject * @@ -2840,7 +2867,21 @@ rv = _steal_accumulate(rval, encoded); } else if (PyInt_Check(obj) || PyLong_Check(obj)) { - PyObject *encoded = PyObject_Str(obj); + PyObject *encoded; + if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj)) { + encoded = PyObject_Str(obj); + } + else { + /* See #118, do not trust custom str/repr */ + PyObject *tmp = PyObject_CallFunctionObjArgs((PyObject *)&PyLong_Type, obj, NULL); + if (tmp == NULL) { + encoded = NULL; + } + else { + encoded = PyObject_Str(tmp); + Py_DECREF(tmp); + } + } if (encoded != NULL) { encoded = maybe_quote_bigint(s, encoded, obj); if (encoded == NULL) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson/encoder.py new/simplejson-3.7.2/simplejson/encoder.py --- old/simplejson-3.6.5/simplejson/encoder.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.7.2/simplejson/encoder.py 2015-05-22 18:21:25.000000000 +0200 @@ -3,7 +3,8 @@ from __future__ import absolute_import import re from operator import itemgetter -from decimal import Decimal +# Do not import Decimal directly to avoid reload issues +import decimal from .compat import u, unichr, binary_type, string_types, integer_types, PY3 def _import_speedups(): try: @@ -311,6 +312,9 @@ elif o == _neginf: text = '-Infinity' else: + if type(o) != float: + # See #118, do not trust custom str/repr + o = float(o) return _repr(o) if ignore_nan: @@ -334,7 +338,7 @@ self.namedtuple_as_object, self.tuple_as_array, int_as_string_bitcount, self.item_sort_key, self.encoding, self.for_json, - self.ignore_nan, Decimal) + self.ignore_nan, decimal.Decimal) else: _iterencode = _make_iterencode( markers, self.default, _encoder, self.indent, floatstr, @@ -343,7 +347,7 @@ self.namedtuple_as_object, self.tuple_as_array, int_as_string_bitcount, self.item_sort_key, self.encoding, self.for_json, - Decimal=Decimal) + Decimal=decimal.Decimal) try: return _iterencode(o, 0) finally: @@ -386,7 +390,7 @@ _PY3=PY3, ValueError=ValueError, string_types=string_types, - Decimal=Decimal, + Decimal=None, dict=dict, float=float, id=id, @@ -396,6 +400,8 @@ str=str, tuple=tuple, ): + if _use_decimal and Decimal is None: + Decimal = decimal.Decimal if _item_sort_key and not callable(_item_sort_key): raise TypeError("item_sort_key must be None or callable") elif _sort_keys and not _item_sort_key: @@ -412,6 +418,9 @@ or _int_as_string_bitcount < 1 ) + if type(value) not in integer_types: + # See #118, do not trust custom str/repr + value = int(value) if ( skip_quoting or (-1 << _int_as_string_bitcount) @@ -501,6 +510,9 @@ elif key is None: key = 'null' elif isinstance(key, integer_types): + if key not in integer_types: + # See #118, do not trust custom str/repr + key = int(key) key = str(key) elif _use_decimal and isinstance(key, Decimal): key = str(key) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson/tests/__init__.py new/simplejson-3.7.2/simplejson/tests/__init__.py --- old/simplejson-3.6.5/simplejson/tests/__init__.py 2014-07-22 22:30:14.000000000 +0200 +++ new/simplejson-3.7.2/simplejson/tests/__init__.py 2015-05-18 19:39:10.000000000 +0200 @@ -62,6 +62,7 @@ 'simplejson.tests.test_namedtuple', 'simplejson.tests.test_tool', 'simplejson.tests.test_for_json', + 'simplejson.tests.test_subclass', ])) suite = get_suite() import simplejson diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson/tests/test_subclass.py new/simplejson-3.7.2/simplejson/tests/test_subclass.py --- old/simplejson-3.6.5/simplejson/tests/test_subclass.py 1970-01-01 01:00:00.000000000 +0100 +++ new/simplejson-3.7.2/simplejson/tests/test_subclass.py 2015-05-18 20:36:17.000000000 +0200 @@ -0,0 +1,37 @@ +from unittest import TestCase +import simplejson as json + +from decimal import Decimal + +class AlternateInt(int): + def __repr__(self): + return 'invalid json' + __str__ = __repr__ + + +class AlternateFloat(float): + def __repr__(self): + return 'invalid json' + __str__ = __repr__ + + +# class AlternateDecimal(Decimal): +# def __repr__(self): +# return 'invalid json' + + +class TestSubclass(TestCase): + def test_int(self): + self.assertEqual(json.dumps(AlternateInt(1)), '1') + self.assertEqual(json.dumps(AlternateInt(-1)), '-1') + self.assertEqual(json.loads(json.dumps({AlternateInt(1): 1})), {'1': 1}) + + def test_float(self): + self.assertEqual(json.dumps(AlternateFloat(1.0)), '1.0') + self.assertEqual(json.dumps(AlternateFloat(-1.0)), '-1.0') + self.assertEqual(json.loads(json.dumps({AlternateFloat(1.0): 1})), {'1.0': 1}) + + # NOTE: Decimal subclasses are not supported as-is + # def test_decimal(self): + # self.assertEqual(json.dumps(AlternateDecimal('1.0')), '1.0') + # self.assertEqual(json.dumps(AlternateDecimal('-1.0')), '-1.0') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson.egg-info/PKG-INFO new/simplejson-3.7.2/simplejson.egg-info/PKG-INFO --- old/simplejson-3.6.5/simplejson.egg-info/PKG-INFO 2014-10-24 17:18:12.000000000 +0200 +++ new/simplejson-3.7.2/simplejson.egg-info/PKG-INFO 2015-05-22 18:34:39.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: simplejson -Version: 3.6.5 +Version: 3.7.2 Summary: Simple, fast, extensible JSON encoder/decoder for Python Home-page: http://github.com/simplejson/simplejson Author: Bob Ippolito diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/simplejson-3.6.5/simplejson.egg-info/SOURCES.txt new/simplejson-3.7.2/simplejson.egg-info/SOURCES.txt --- old/simplejson-3.6.5/simplejson.egg-info/SOURCES.txt 2014-10-24 17:18:13.000000000 +0200 +++ new/simplejson-3.7.2/simplejson.egg-info/SOURCES.txt 2015-05-22 18:34:39.000000000 +0200 @@ -42,6 +42,7 @@ simplejson/tests/test_scanstring.py simplejson/tests/test_separators.py simplejson/tests/test_speedups.py +simplejson/tests/test_subclass.py simplejson/tests/test_tool.py simplejson/tests/test_tuple.py simplejson/tests/test_unicode.py \ No newline at end of file