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 2022-05-30 12:44:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-json5 (Old) and /work/SRC/openSUSE:Factory/.python-json5.new.2254 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-json5" Mon May 30 12:44:07 2022 rev:6 rq:979749 version:0.9.8 Changes: -------- --- /work/SRC/openSUSE:Factory/python-json5/python-json5.changes 2021-10-26 20:13:52.146015363 +0200 +++ /work/SRC/openSUSE:Factory/.python-json5.new.2254/python-json5.changes 2022-05-30 12:45:03.668479227 +0200 @@ -1,0 +2,12 @@ +Sun May 29 20:17:37 UTC 2022 - Dirk M??ller <dmuel...@suse.com> + +- update to 0.9.8: + * Fixed error reporting in some cases due to how parsing was handling + nested rules in the grammar - previously the reported location for + the error could be far away from the point where it actually happened. + * Fixed behavior of `default` fn in `dump` and `dumps`. Previously + we didn't require the function to return a string, and so we could + end up returning something that wasn't actually valid. This change + now matches the behavior in the `json` module. + +------------------------------------------------------------------- Old: ---- pyjson5-0.9.6.tar.gz New: ---- pyjson5-0.9.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-json5.spec ++++++ --- /var/tmp/diff_new_pack.XvFquu/_old 2022-05-30 12:45:04.168479892 +0200 +++ /var/tmp/diff_new_pack.XvFquu/_new 2022-05-30 12:45:04.176479903 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-json5 # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,7 +25,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-json5 -Version: 0.9.6 +Version: 0.9.8 Release: 0 Summary: A Python implementation of the JSON5 data format License: Apache-2.0 ++++++ pyjson5-0.9.6.tar.gz -> pyjson5-0.9.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/README.md new/pyjson5-0.9.8/README.md --- old/pyjson5-0.9.6/README.md 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/README.md 2022-05-09 03:47:03.000000000 +0200 @@ -57,6 +57,19 @@ ## Version History / Release Notes +* v0.9.8 (2022-05-08) + * [GitHub issue #47](https://github.com/dpranke/pyjson5/issues/47) + Fixed error reporting in some cases due to how parsing was handling + nested rules in the grammar - previously the reported location for + the error could be far away from the point where it actually happened. + +* v0.9.7 (2022-05-06) + * [GitHub issue #52](https://github.com/dpranke/pyjson5/issues/52) + Fixed behavior of `default` fn in `dump` and `dumps`. Previously + we didn't require the function to return a string, and so we could + end up returning something that wasn't actually valid. This change + now matches the behavior in the `json` module. *Note: This is a + potentially breaking change.* * 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 @@ -65,7 +78,7 @@ 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) + * [GitHub issue #46](https://github.com/dpranke/pyjson5/issues/36) Fix incorrect serialization of custom subtypes * Make it possible to run the tests if `hypothesis` isn't installed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/json5/json5.g new/pyjson5-0.9.8/json5/json5.g --- old/pyjson5-0.9.6/json5/json5.g 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/json5/json5.g 2022-05-09 03:47:03.000000000 +0200 @@ -4,7 +4,7 @@ ws = '\u0020' | eol | comment | '\u0009' | '\u000B' | '\u000C' | '\u00A0' | '\uFEFF' - | anything:x ?( is_unicat(x, 'Zs') ) -> x + | ~~(anything:x ?( is_unicat(x, 'Zs') )) anything:x -> x eol = '\u000D' '\u000A' | '\u000D' | '\u000A' | '\u2028' | '\u2029' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/json5/lib.py new/pyjson5-0.9.8/json5/lib.py --- old/pyjson5-0.9.6/json5/lib.py 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/json5/lib.py 2022-05-09 03:47:03.000000000 +0200 @@ -19,7 +19,6 @@ from .parser import Parser - if sys.version_info[0] < 3: str_types = (str, unicode) str = unicode # pylint: disable=redefined-builtin, invalid-name @@ -151,27 +150,36 @@ """Serialize ``obj`` to a JSON5-formatted stream to ``fp`` (a ``.write()``- supporting file-like object). - Supports the same arguments as ``json.dumps()``, except that: + Supports the same arguments as ``json.dump()``, except that: - The ``cls`` keyword is not supported. - The ``encoding`` keyword is ignored; Unicode strings are always written. - By default, object keys that are legal identifiers are not quoted; - if you pass quote_keys=True, they will be. + if you pass ``quote_keys=True``, they will be. - By default, if lists and objects span multiple lines of output (i.e., when ``indent`` >=0), the last item will have a trailing comma - after it. If you pass ``trailing_commas=False, it will not. - - If you use a number, a boolean, or None as a key value in a dict, - it will be converted to the corresponding json string value, e.g. - "1", "true", or "null". By default, dump() will match the `json` - modules behavior and produce ill-formed JSON if you mix keys of - different types that have the same converted value, e.g.: - {1: "foo", "1": "bar"} produces '{"1": "foo", "1": "bar"}', an - object with duplicated keys. If you pass allow_duplicate_keys=False, + after it. If you pass ``trailing_commas=False``, it will not. + - If you use a number, a boolean, or ``None`` as a key value in a dict, + it will be converted to the corresponding JSON string value, e.g. + "1", "true", or "null". By default, ``dump()`` will match the `json` + modules behavior and produce malformed JSON if you mix keys of + different types that have the same converted value; e.g., + ``{1: "foo", "1": "bar"}`` produces '{"1": "foo", "1": "bar"}', an + object with duplicated keys. If you pass ``allow_duplicate_keys=False``, an exception will be raised instead. - - Calling ``dumps(obj, fp, quote_keys=True, trailing_commas=False, - allow_duplicate_keys=True)`` - should produce exactly the same output as ``json.dumps(obj, fp).`` + - If `quote_keys` is true, then keys of objects will be enclosed in quotes, + as in regular JSON. Otheriwse, keys will not be enclosed in quotes unless + they contain whitespace. + - If `trailing_commas` is false, then commas will not be inserted after + the final elements of objects and arrays, as in regular JSON. Otherwise, + such commas will be inserted. + - If `allow_duplicate_keys` is false, then only the last entry with a given + key will be written. Otherwise, all entries with the same key will be + written. + + Calling ``dump(obj, fp, quote_keys=True, trailing_commas=False, \ + allow_duplicate_keys=True)`` + should produce exactly the same output as ``json.dump(obj, fp).`` """ fp.write(str(dumps(obj=obj, skipkeys=skipkeys, ensure_ascii=ensure_ascii, @@ -192,23 +200,31 @@ Supports the same arguments as ``json.dumps()``, except that: - The ``cls`` keyword is not supported. - - The ``encoding`` keyword is ignored; Unicode strings are always returned. + - The ``encoding`` keyword is ignored; Unicode strings are always written. - By default, object keys that are legal identifiers are not quoted; - if you pass quote_keys=True, they will be. + if you pass ``quote_keys=True``, they will be. - By default, if lists and objects span multiple lines of output (i.e., when ``indent`` >=0), the last item will have a trailing comma - after it. If you pass ``trailing_commas=False, it will not. - - If you use a number, a boolean, or None as a key value in a dict, - it will be converted to the corresponding json string value, e.g. - "1", "true", or "null". By default, dump() will match the ``json`` - module's behavior and produce ill-formed JSON if you mix keys of - different types that have the same converted value, e.g.: - {1: "foo", "1": "bar"} produces '{"1": "foo", "1": "bar"}', an + after it. If you pass ``trailing_commas=False``, it will not. + - If you use a number, a boolean, or ``None`` as a key value in a dict, + it will be converted to the corresponding JSON string value, e.g. + "1", "true", or "null". By default, ``dump()`` will match the `json` + modules behavior and produce malformed JSON if you mix keys of + different types that have the same converted value; e.g., + ``{1: "foo", "1": "bar"}`` produces '{"1": "foo", "1": "bar"}', an object with duplicated keys. If you pass ``allow_duplicate_keys=False``, an exception will be raised instead. + - If `quote_keys` is true, then keys of objects will be enclosed in quotes, + as in regular JSON. Otheriwse, keys will not be enclosed in quotes unless + they contain whitespace. + - If `trailing_commas` is false, then commas will not be inserted after + the final elements of objects and arrays, as in regular JSON. Otherwise, + such commas will be inserted. + - If `allow_duplicate_keys` is false, then only the last entry with a given + key will be written. Otherwise, all entries with the same key will be + written. - - Calling ``dumps(obj, quote_keys=True, trailing_commas=False, + Calling ``dumps(obj, quote_keys=True, trailing_commas=False, \ allow_duplicate_keys=True)`` should produce exactly the same output as ``json.dumps(obj).`` """ @@ -290,7 +306,6 @@ item_sep, kv_sep = separators item_sep += indent_str - level += 1 if seen is not None: i = id(obj) @@ -306,17 +321,22 @@ check_circular, allow_nan, indent, separators, default, sort_keys, quote_keys, trailing_commas, - allow_duplicate_keys, seen, level, + allow_duplicate_keys, seen, level + 1, item_sep, kv_sep, indent_str, end_str) elif hasattr(obj, '__getitem__') and hasattr(obj, '__iter__'): s = _dump_array(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, separators, default, sort_keys, quote_keys, trailing_commas, - allow_duplicate_keys, seen, level, + allow_duplicate_keys, seen, level + 1, item_sep, indent_str, end_str) else: - s = default(obj) + s = _dumps(default(obj), skipkeys, ensure_ascii, + check_circular, allow_nan, indent, + separators, default, sort_keys, + quote_keys, trailing_commas, + allow_duplicate_keys, seen, level, + is_key)[1] if seen is not None: seen.remove(i) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/json5/parser.py new/pyjson5-0.9.8/json5/parser.py --- old/pyjson5-0.9.6/json5/parser.py 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/json5/parser.py 2022-05-09 03:47:03.000000000 +0200 @@ -70,11 +70,13 @@ def _not(self, rule): p = self.pos + errpos = self.errpos rule() if self.failed: self._succeed(None, p) else: self._rewind(p) + self.errpos = errpos self._fail() def _opt(self, rule): @@ -100,8 +102,6 @@ rule() if self.failed: self._rewind(p) - if p < self.errpos: - self.errpos = p break else: vs.append(self.val) @@ -200,11 +200,21 @@ def _ws__c8_(self): self._push('ws__c8') - self._seq([lambda: self._bind(self._anything_, 'x'), self._ws__c8__s1_, + self._seq([self._ws__c8__s0_, lambda: self._bind(self._anything_, 'x'), lambda: self._succeed(self._get('x'))]) self._pop('ws__c8') - def _ws__c8__s1_(self): + def _ws__c8__s0_(self): + self._not(lambda: self._not(self._ws__c8__s0_n_n_)) + + def _ws__c8__s0_n_n_(self): + (lambda: self._choose([self._ws__c8__s0_n_n_g__c0_]))() + + def _ws__c8__s0_n_n_g__c0_(self): + self._seq([lambda: self._bind(self._anything_, 'x'), + self._ws__c8__s0_n_n_g__c0__s1_]) + + def _ws__c8__s0_n_n_g__c0__s1_(self): v = self._is_unicat(self._get('x'), 'Zs') if v: self._succeed(v) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/json5/version.py new/pyjson5-0.9.8/json5/version.py --- old/pyjson5-0.9.6/json5/version.py 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/json5/version.py 2022-05-09 03:47:03.000000000 +0200 @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = '0.9.6' +VERSION = '0.9.8' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyjson5-0.9.6/tests/lib_test.py new/pyjson5-0.9.8/tests/lib_test.py --- old/pyjson5-0.9.6/tests/lib_test.py 2021-06-22 02:24:13.000000000 +0200 +++ new/pyjson5-0.9.8/tests/lib_test.py 2022-05-09 03:47:03.000000000 +0200 @@ -18,7 +18,6 @@ import os import sys import unittest - from collections import OrderedDict from string import printable @@ -28,7 +27,6 @@ # 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( @@ -254,6 +252,21 @@ self.check(u'\u2028 1', 1) self.check(u'\u2029 1', 1) + def test_error_reporting(self): + self.check_fail('[ ,]', + err='<string>:1 Unexpected "," at column 3') + + self.check_fail( + '{\n' + ' version: "1.0",\n' + ' author: "John Smith",\n' + ' people : [\n' + ' "Monty",\n' + ' "Python"foo\n' + ' ]\n' + '}\n', + err='<string>:6 Unexpected "f" at column 17') + class TestDump(unittest.TestCase): def test_basic(self): @@ -375,7 +388,7 @@ self.assertRaises(TypeError, json5.dumps, set()) self.assertEqual(json5.dumps(set(), default=_custom_serializer), - 'something') + '"something"') def test_ensure_ascii(self): self.check(u'\u00fc', '"\\u00fc"')