Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-json5 for openSUSE:Factory checked in at 2021-06-23 17:38:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-json5 (Old) and /work/SRC/openSUSE:Factory/.python-json5.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-json5" Wed Jun 23 17:38:10 2021 rev:4 rq:901357 version:0.9.6 Changes: -------- --- /work/SRC/openSUSE:Factory/python-json5/python-json5.changes 2020-05-26 17:48:58.319834737 +0200 +++ /work/SRC/openSUSE:Factory/.python-json5.new.2625/python-json5.changes 2021-06-23 17:38:12.600469658 +0200 @@ -1,0 +2,10 @@ +Tue Jun 22 08:52:38 UTC 2021 - Paolo Stivanin <i...@paolostivanin.com> + +- Update to 0.9.6 + * Bump development status classifier to 5 - Production/Stable + * Bump the tested Python versions to 2.7, 3.8 and 3.9 + * GitHub issue #46 Fix incorrect serialization of custom subtypes + * Make it possible to run the tests if hypothesis isn't installed. + * Miscellaneous non-source cleanups in the repo + +------------------------------------------------------------------- Old: ---- pyjson5-0.9.4.tar.gz New: ---- pyjson5-0.9.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-json5.spec ++++++ --- /var/tmp/diff_new_pack.4oAHV1/_old 2021-06-23 17:38:13.112470363 +0200 +++ /var/tmp/diff_new_pack.4oAHV1/_new 2021-06-23 17:38:13.112470363 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-json5 # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-json5 -Version: 0.9.4 +Version: 0.9.6 Release: 0 Summary: A Python implementation of the JSON5 data format License: Apache-2.0 @@ -31,7 +31,7 @@ BuildRequires: python-rpm-macros Requires: python-setuptools Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch %python_subpackages ++++++ pyjson5-0.9.4.tar.gz -> pyjson5-0.9.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/.github/workflows/ci.yml new/pyjson5-0.9.6/.github/workflows/ci.yml --- old/pyjson5-0.9.4/.github/workflows/ci.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pyjson5-0.9.6/.github/workflows/ci.yml 2021-06-22 02:24:13.000000000 +0200 @@ -0,0 +1,24 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + - name: Run tests + run: python setup.py test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/README.md new/pyjson5-0.9.6/README.md --- old/pyjson5-0.9.4/README.md 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/README.md 2021-06-22 02:24:13.000000000 +0200 @@ -50,8 +50,30 @@ keyword *is* supported, though, and might be able to serve as a workaround. +## Running the tests +To run the tests, setup a venv and install the required dependencies with +`pip install -e '.[dev]'`, then run the tests with `python setup.py test`. + + ## Version History / Release Notes +* v0.9.6 (2021-06-21) + * Bump development status classifier to 5 - Production/Stable, which + the library feels like it is at this point. If I do end up significantly + reworking things to speed it up and/or to add round-trip editing, + that'll likely be a 2.0. If this version has no reported issues, + I'll likely promote it to 1.0. + * Also bump the tested Python versions to 2.7, 3.8 and 3.9, though + earlier Python3 versions will likely continue to work as well. + * [GitHub issue #46](https://github.dpranke/pyjson5/issues/36) + Fix incorrect serialization of custom subtypes + * Make it possible to run the tests if `hypothesis` isn't installed. + +* v0.9.5 (2020-05-26) + * Miscellaneous non-source cleanups in the repo, including setting + up GitHub Actions for a CI system. No changes to the library from + v0.9.4, other than updating the version. + * v0.9.4 (2020-03-26) * [GitHub pull #38](https://github.com/dpranke/pyjson5/pull/38) Fix from fred...@fornwall.net for dumps() crashing when passed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/benchmarks/run.py new/pyjson5-0.9.6/benchmarks/run.py --- old/pyjson5-0.9.4/benchmarks/run.py 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/benchmarks/run.py 2021-06-22 02:24:13.000000000 +0200 @@ -28,6 +28,7 @@ import json5 # pylint: disable=wrong-import-position + ALL_BENCHMARKS = ( 'ios-simulator.json', 'mb_config.json', @@ -35,7 +36,9 @@ 'chromium.perf.json', ) -DEFAULT_ITERATIONS = 1 + +DEFAULT_ITERATIONS = 3 + def main(): parser = argparse.ArgumentParser() @@ -67,7 +70,8 @@ all_times = [] for i, c in enumerate(file_contents): - times = [] + json_time = 0.0 + json5_time = 0.0 for _ in range(args.num_iterations): start = time.time() json_obj = json.loads(c, cls=maker) @@ -75,16 +79,30 @@ json5_obj = json5.loads(c) end = time.time() - json_time = mid - start - json5_time = end - mid - times.append((json_time, json5_time)) + json_time += mid - start + json5_time += end - mid assert json5_obj == json_obj - all_times.append(times) + all_times.append((json_time, json5_time)) - for i, times in enumerate(all_times): - avg = sum((json5_time / json_time) - for json_time, json5_time in times) / args.num_iterations - print("%-20s: %5.1f" % (args.benchmarks[i], avg)) + for i, (json_time, json5_time) in enumerate(all_times): + fname = os.path.basename(args.benchmarks[i]) + if json5_time and json_time: + if json5_time > json_time: + avg = json5_time / json_time + print("%-20s: JSON was %5.1fx faster (%.6fs to %.6fs)" % ( + fname, avg, json_time, json5_time)) + else: + avg = json_time / json5_time + print("%-20s: JSON5 was %5.1fx faster (%.6fs to %.6fs)" % ( + fname, avg, json5_time, json_time)) + elif json5_time: + print("%-20s: JSON5 took %.6f secs, JSON was too fast to measure" % + (fname, json5_time)) + elif json_time: + print("%-20s: JSON took %.6f secs, JSON5 was too fast to measure" % + (fname, json_time)) + else: + print("%-20s: both were too fast to measure" % (fname,)) return 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/json5/lib.py new/pyjson5-0.9.6/json5/lib.py --- old/pyjson5-0.9.4/json5/lib.py 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/json5/lib.py 2021-06-22 02:24:13.000000000 +0200 @@ -21,8 +21,10 @@ if sys.version_info[0] < 3: + str_types = (str, unicode) str = unicode # pylint: disable=redefined-builtin, invalid-name else: + str_types = (str,) long = int # pylint: disable=redefined-builtin, invalid-name @@ -240,24 +242,23 @@ separators, default, sort_keys, quote_keys, trailing_commas, allow_duplicate_keys, seen, level, is_key): - s = None if obj is True: s = u'true' - if obj is False: + elif obj is False: s = u'false' - if obj is None: + elif obj is None: s = u'null' - - t = type(obj) - if t == type('') or t == type(u''): + elif isinstance(obj, str_types): if (is_key and _is_ident(obj) and not quote_keys and not _is_reserved_word(obj)): return True, obj return True, _dump_str(obj, ensure_ascii) - if t is float: + elif isinstance(obj, float): s = _dump_float(obj,allow_nan) - if t is int: + elif isinstance(obj, int): s = str(obj) + else: + s = None if is_key: if s is not None: @@ -300,14 +301,14 @@ # In Python3, we'd check if this was an abc.Mapping or an abc.Sequence. # For now, just check for the attrs we need to iterate over the object. - if hasattr(t, 'keys') and hasattr(t, '__getitem__'): + if hasattr(obj, 'keys') and hasattr(obj, '__getitem__'): s = _dump_dict(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, separators, default, sort_keys, quote_keys, trailing_commas, allow_duplicate_keys, seen, level, item_sep, kv_sep, indent_str, end_str) - elif hasattr(t, '__getitem__') and hasattr(t, '__iter__'): + elif hasattr(obj, '__getitem__') and hasattr(obj, '__iter__'): s = _dump_array(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, separators, default, sort_keys, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/json5/version.py new/pyjson5-0.9.6/json5/version.py --- old/pyjson5-0.9.4/json5/version.py 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/json5/version.py 2021-06-22 02:24:13.000000000 +0200 @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = '0.9.4' +VERSION = '0.9.6' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/setup.py new/pyjson5-0.9.6/setup.py --- old/pyjson5-0.9.4/setup.py 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/setup.py 2021-06-22 02:24:13.000000000 +0200 @@ -37,6 +37,11 @@ }, install_requires=[ ], + extras_require={ + 'dev': [ + 'hypothesis' + ] + }, version=json5.VERSION, author='Dirk Pranke', author_email='dpra...@chromium.org', @@ -46,12 +51,13 @@ url='https://github.com/dpranke/pyjson5', license='Apache', classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.4/tests/lib_test.py new/pyjson5-0.9.6/tests/lib_test.py --- old/pyjson5-0.9.4/tests/lib_test.py 2020-03-27 00:12:33.000000000 +0100 +++ new/pyjson5-0.9.6/tests/lib_test.py 2021-06-22 02:24:13.000000000 +0200 @@ -13,15 +13,38 @@ # limitations under the License. import io +import json import math import os import sys import unittest from collections import OrderedDict +from string import printable import json5 +try: + # Make the `hypothesis` library optional, so that the other tests will + # still run if it isn't installed. + import hypothesis.strategies as some + + from hypothesis import given + + some_json = some.recursive( + some.none() | + some.booleans() | + some.floats(allow_nan=False) | + some.text(printable), + lambda children: some.lists(children, min_size=1) + | some.dictionaries(some.text(printable), children, min_size=1), + ) +except ImportError as e: + def given(x): + def func(y): + pass + return func + some_json = {} class TestLoads(unittest.TestCase): maxDiff = None @@ -295,6 +318,55 @@ z['y']['x'] = x self.assertRaises(ValueError, json5.dumps, z) + def test_custom_arrays(self): + class MyArray(object): + def __iter__(self): + yield 0 + yield 1 + yield 1 + + def __getitem__(self, i): + return 0 if i == 0 else 1 + + def __len__(self): + return 3 + + self.assertEqual(json5.dumps(MyArray()), '[0, 1, 1]') + + def test_custom_numbers(self): + class MyInt(int): + pass + + self.assertEqual(json5.dumps(MyInt(5)), '5') + + class MyFloat(float): + pass + + self.assertEqual(json5.dumps(MyFloat(0.5)), '0.5') + + def test_custom_objects(self): + class MyDict(object): + def __iter__(self): + yield ('a', 1) + yield ('b', 2) + + def keys(self): + return ['a', 'b'] + + def __getitem__(self, k): + return {'a': 1, 'b': 2}[k] + + def __len__(self): + return 2 + + self.assertEqual(json5.dumps(MyDict()), '{a: 1, b: 2}') + + def test_custom_strings(self): + class MyStr(str): + pass + + self.assertEqual(json5.dumps({'foo': MyStr('bar')}), '{foo: "bar"}') + def test_default(self): def _custom_serializer(obj): @@ -425,6 +497,17 @@ def test_empty_key(self): self.assertEqual(json5.dumps({'': 'value'}), '{"": "value"}') + @given(some_json) + def test_object_roundtrip(self, input_object): + dumped_string_json = json.dumps(input_object) + dumped_string_json5 = json5.dumps(input_object) + + parsed_object_json = json5.loads(dumped_string_json) + parsed_object_json5 = json5.loads(dumped_string_json5) + + assert parsed_object_json == input_object + assert parsed_object_json5 == input_object + if __name__ == '__main__': # pragma: no cover unittest.main()