Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-jsonpickle for openSUSE:Factory checked in at 2023-12-14 22:03:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jsonpickle (Old) and /work/SRC/openSUSE:Factory/.python-jsonpickle.new.25432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonpickle" Thu Dec 14 22:03:17 2023 rev:12 rq:1132963 version:3.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jsonpickle/python-jsonpickle.changes 2023-06-16 16:56:07.938163374 +0200 +++ /work/SRC/openSUSE:Factory/.python-jsonpickle.new.25432/python-jsonpickle.changes 2023-12-14 22:03:19.592469820 +0100 @@ -1,0 +2,18 @@ +Wed Dec 13 16:18:51 UTC 2023 - Ben Greiner <c...@bnavigator.de> + +- Update to 3.0.2 + * Properly raise warning if a custom pickling handler returns + None. (#433) + * Fix issue with serialization of certain sklearn objects + breaking when the numpy handler was enabled. (#431) (+434) + * Allow custom backends to not implement _encoder_options (#436) + (+446) + * Implement compatibility with pandas 2 (+446) + * Fix encoding/decoding of dictionary subclasses with referencing + (+455) + * Fix depth tracking for list/dict referencing (+456) +- Drop pandas2.patch +- Skip a noncritical test due to pandas built with Cython 3 + gh#jsonpickle/jsonpickle#460 + +------------------------------------------------------------------- Old: ---- jsonpickle-3.0.1.tar.gz pandas2.patch New: ---- jsonpickle-3.0.2.tar.gz BETA DEBUG BEGIN: Old: * Fix depth tracking for list/dict referencing (+456) - Drop pandas2.patch - Skip a noncritical test due to pandas built with Cython 3 BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jsonpickle.spec ++++++ --- /var/tmp/diff_new_pack.yWXvLH/_old 2023-12-14 22:03:20.388498532 +0100 +++ /var/tmp/diff_new_pack.yWXvLH/_new 2023-12-14 22:03:20.392498676 +0100 @@ -18,24 +18,23 @@ %{?sle15_python_module_pythons} Name: python-jsonpickle -Version: 3.0.1 +Version: 3.0.2 Release: 0 Summary: Python library for serializing any arbitrary object graph into JSON License: BSD-3-Clause URL: https://github.com/jsonpickle/jsonpickle Source: https://files.pythonhosted.org/packages/source/j/jsonpickle/jsonpickle-%{version}.tar.gz -# PATCH-FIX-UPSTREAM https://github.com/jsonpickle/jsonpickle/commit/a24240bfdec6a9d5172c2f25e19654d23ffc61e1 Implement compatibility with pandas 2 -Patch: pandas2.patch BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module importlib_metadata if %python-base < 3.8} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools >= 42} BuildRequires: %{python_module setuptools_scm >= 3.4.1} -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros -Recommends: python-simplejson -Suggests: python-ujson -Suggests: python-numpy -Suggests: python-pandas +%if %python_version_nodots < 38 +Requires: python-importlib_metadata +%endif BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module SQLAlchemy} @@ -61,19 +60,22 @@ sed -i 's/ --cov//' pytest.ini %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check # test_multindex_dataframe_roundtrip is flaky on i586 -%pytest -ra -k "not test_multindex_dataframe_roundtrip" +donttest="test_multindex_dataframe_roundtrip" +# https://github.com/jsonpickle/jsonpickle/issues/460 +donttest+=" or test_timedelta_index_roundtrip" +%pytest -ra -k "not ($donttest)" %files %{python_files} %license LICENSE %doc README.rst CHANGES.rst %{python_sitelib}/jsonpickle -%{python_sitelib}/jsonpickle-%{version}*-info +%{python_sitelib}/jsonpickle-%{version}.dist-info ++++++ jsonpickle-3.0.1.tar.gz -> jsonpickle-3.0.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/.github/workflows/lint.yml new/jsonpickle-3.0.2/.github/workflows/lint.yml --- old/jsonpickle-3.0.1/.github/workflows/lint.yml 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/.github/workflows/lint.yml 2023-06-15 19:27:19.000000000 +0200 @@ -15,7 +15,7 @@ - name: Checkout code uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: "3.10" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/.github/workflows/test.yml new/jsonpickle-3.0.2/.github/workflows/test.yml --- old/jsonpickle-3.0.1/.github/workflows/test.yml 2022-12-11 23:29:25.000000000 +0100 +++ new/jsonpickle-3.0.2/.github/workflows/test.yml 2023-06-15 19:27:19.000000000 +0200 @@ -19,7 +19,7 @@ - TOXENV: sa13 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -29,7 +29,7 @@ - name: Get pip cache dir id: pip-cache run: | - echo "::set-output name=dir::$(pip cache dir)" + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - name: Cache uses: actions/cache@v3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/CHANGES.rst new/jsonpickle-3.0.2/CHANGES.rst --- old/jsonpickle-3.0.1/CHANGES.rst 2022-12-16 20:10:47.000000000 +0100 +++ new/jsonpickle-3.0.2/CHANGES.rst 2023-05-26 20:17:00.000000000 +0200 @@ -1,3 +1,11 @@ +v3.0.2 +====== + * Properly raise warning if a custom pickling handler returns None. (#433) + * Fix issue with serialization of certain sklearn objects breaking when + the numpy handler was enabled. (#431) (+434) + * Allow custom backends to not implement _encoder_options (#436) (+446) + * Implement compatibility with pandas 2 (+446) + v3.0.1 ====== * Remove accidental pin of setuptools to versions below 59. This allows diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/PKG-INFO new/jsonpickle-3.0.2/PKG-INFO --- old/jsonpickle-3.0.1/PKG-INFO 2022-12-18 00:45:49.252404700 +0100 +++ new/jsonpickle-3.0.2/PKG-INFO 2023-08-13 20:49:20.744231200 +0200 @@ -1,11 +1,10 @@ Metadata-Version: 2.1 Name: jsonpickle -Version: 3.0.1 +Version: 3.0.2 Summary: Python library for serializing any arbitrary object graph into JSON Home-page: https://github.com/jsonpickle/jsonpickle Author: David Aguilar Author-email: dav...@gmail.com -License: UNKNOWN Keywords: json pickle,json,pickle,marshal,serialization,JavaScript Object Notation Platform: POSIX Platform: Windows @@ -18,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: JavaScript Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development :: Libraries :: Python Modules @@ -182,5 +182,3 @@ GPG Signing =========== Releases before v3.0.0 are signed with `davvid's key <https://keys.openpgp.org/vks/v1/by-fingerprint/FA41BF59C1B48E8C5F3DA61C8CE26BF4A9F606B0>`_. v3.0.0 and after are likely signed by `Theelx's key <https://github.com/Theelx.gpg>`_. All upcoming releases should be signed by one of these two keys, usually Theelx's key. - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle/backend.py new/jsonpickle-3.0.2/jsonpickle/backend.py --- old/jsonpickle-3.0.1/jsonpickle/backend.py 2022-12-01 17:36:11.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle/backend.py 2023-05-23 01:46:28.000000000 +0200 @@ -137,7 +137,6 @@ return True def load_backend(self, name, dumps='dumps', loads='loads', loads_exc=ValueError): - """Load a JSON backend by name. This method loads a backend and sets up references to that diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle/ext/numpy.py new/jsonpickle-3.0.2/jsonpickle/ext/numpy.py --- old/jsonpickle-3.0.1/jsonpickle/ext/numpy.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle/ext/numpy.py 2023-08-13 20:22:05.000000000 +0200 @@ -324,6 +324,9 @@ else: # decode array view, which references the data of another array base = self.context.restore(base, reset=False) + if not isinstance(base, np.ndarray): + # the object is probably a nested list + base = np.array(base) assert ( base.flags.forc ), "Current implementation assumes base is C or F contiguous" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle/ext/pandas.py new/jsonpickle-3.0.2/jsonpickle/ext/pandas.py --- old/jsonpickle-3.0.1/jsonpickle/ext/pandas.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle/ext/pandas.py 2023-05-26 19:34:56.000000000 +0200 @@ -62,10 +62,13 @@ parse_dates = [] converters = {} timedeltas = [] + # this is only for pandas v2+ due to a backwards-incompatible change + parse_datetime_v2 = {} dtype = {} for k, v in meta_dtypes.items(): if v.startswith('datetime'): parse_dates.append(k) + parse_datetime_v2[k] = v elif v.startswith('complex'): converters[k] = complex elif v.startswith('timedelta'): @@ -79,6 +82,7 @@ dtype=dtype, header=header, parse_dates=parse_dates, converters=converters ), timedeltas, + parse_datetime_v2, ) @@ -104,7 +108,7 @@ def restore(self, data): csv, meta = self.pp.restore_pandas(data) - params, timedeltas = make_read_csv_params(meta, self.context) + params, timedeltas, parse_datetime_v2 = make_read_csv_params(meta, self.context) # None makes it compatible with objects serialized before # column_levels_names has been introduced. column_level_names = meta.get('column_level_names', None) @@ -115,6 +119,7 @@ ) for col in timedeltas: df[col] = pd.to_timedelta(df[col]) + df = df.astype(parse_datetime_v2) df.set_index(decode(meta['index']), inplace=True) # restore the column level(s) name(s) @@ -143,7 +148,6 @@ class PandasIndexHandler(BaseHandler): - pp = PandasProcessor() index_constructor = pd.Index diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle/pickler.py new/jsonpickle-3.0.2/jsonpickle/pickler.py --- old/jsonpickle-3.0.1/jsonpickle/pickler.py 2022-12-01 18:06:59.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle/pickler.py 2023-08-13 20:29:44.000000000 +0200 @@ -111,8 +111,9 @@ :param include_properties: Include the names and values of class properties in the generated json. Properties are unpickled properly regardless of this setting, this is - meant to be used if processing the json outside of Python. Defaults to - ``False``. + meant to be used if processing the json outside of Python. Certain types + such as sets will not pickle due to not having a native-json equivalent. + Defaults to ``False``. >>> encode('my string') == '"my string"' True @@ -220,7 +221,7 @@ self.include_properties = include_properties def _determine_sort_keys(self): - for _, options in self.backend._encoder_options.values(): + for _, options in getattr(self.backend, '_encoder_options', {}).values(): if options.get("sort_keys", False): # the user has set one of the backends to sort keys return True @@ -368,7 +369,6 @@ max_reached = self._max_reached() try: - in_cycle = _in_cycle(obj, self._objs, max_reached, self.make_refs) if in_cycle: # break the cycle @@ -521,7 +521,10 @@ if handler is not None: if self.unpicklable: data[tags.OBJECT] = class_name - return handler(self).flatten(obj, data) + result = handler(self).flatten(obj, data) + if result is None: + self._pickle_warning(obj) + return result reduce_val = None @@ -771,10 +774,13 @@ data['default_factory'] = value # Sub-classes of dict - if hasattr(obj, '__dict__') and self.unpicklable: - dict_data = {} - self._flatten_dict_obj(obj.__dict__, dict_data) - data['__dict__'] = dict_data + if hasattr(obj, '__dict__') and self.unpicklable and obj != obj.__dict__: + if self._mkref(obj.__dict__): + dict_data = {} + self._flatten_dict_obj(obj.__dict__, dict_data) + data['__dict__'] = dict_data + else: + data['__dict__'] = self._getref(obj.__dict__) return data @@ -785,7 +791,6 @@ self._list_recurse if type(obj) is list else self._flatten_dict_obj ) else: - self._push() return self._getref # We handle tuples and sets by encoding them in a "(tuple|set)dict" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle/unpickler.py new/jsonpickle-3.0.2/jsonpickle/unpickler.py --- old/jsonpickle-3.0.1/jsonpickle/unpickler.py 2022-12-16 20:10:17.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle/unpickler.py 2023-08-13 20:22:05.000000000 +0200 @@ -327,7 +327,7 @@ def _swap_proxies(self): """Replace proxies with their corresponding instances""" - for (obj, attr, proxy, method) in self._proxies: + for obj, attr, proxy, method in self._proxies: method(obj, attr, proxy) self._proxies = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/jsonpickle.egg-info/PKG-INFO new/jsonpickle-3.0.2/jsonpickle.egg-info/PKG-INFO --- old/jsonpickle-3.0.1/jsonpickle.egg-info/PKG-INFO 2022-12-18 00:45:48.000000000 +0100 +++ new/jsonpickle-3.0.2/jsonpickle.egg-info/PKG-INFO 2023-08-13 20:49:20.000000000 +0200 @@ -1,11 +1,10 @@ Metadata-Version: 2.1 Name: jsonpickle -Version: 3.0.1 +Version: 3.0.2 Summary: Python library for serializing any arbitrary object graph into JSON Home-page: https://github.com/jsonpickle/jsonpickle Author: David Aguilar Author-email: dav...@gmail.com -License: UNKNOWN Keywords: json pickle,json,pickle,marshal,serialization,JavaScript Object Notation Platform: POSIX Platform: Windows @@ -18,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: JavaScript Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development :: Libraries :: Python Modules @@ -182,5 +182,3 @@ GPG Signing =========== Releases before v3.0.0 are signed with `davvid's key <https://keys.openpgp.org/vks/v1/by-fingerprint/FA41BF59C1B48E8C5F3DA61C8CE26BF4A9F606B0>`_. v3.0.0 and after are likely signed by `Theelx's key <https://github.com/Theelx.gpg>`_. All upcoming releases should be signed by one of these two keys, usually Theelx's key. - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/pyproject.toml new/jsonpickle-3.0.2/pyproject.toml --- old/jsonpickle-3.0.1/pyproject.toml 2022-12-16 19:49:07.000000000 +0100 +++ new/jsonpickle-3.0.2/pyproject.toml 2023-01-09 17:13:27.000000000 +0100 @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4.1"] +requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4.1"] build-backend = "setuptools.build_meta" [tool.black] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/setup.cfg new/jsonpickle-3.0.2/setup.cfg --- old/jsonpickle-3.0.1/setup.cfg 2022-12-18 00:45:49.252404700 +0100 +++ new/jsonpickle-3.0.2/setup.cfg 2023-08-13 20:49:20.744231200 +0200 @@ -1,6 +1,3 @@ -[bdist_wheel] -universal = 1 - [metadata] license_file = LICENSE name = jsonpickle @@ -19,6 +16,7 @@ Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Programming Language :: JavaScript Operating System :: OS Independent Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/backend_test.py new/jsonpickle-3.0.2/tests/backend_test.py --- old/jsonpickle-3.0.1/tests/backend_test.py 2022-12-01 17:50:41.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/backend_test.py 2023-01-09 17:13:27.000000000 +0100 @@ -159,20 +159,6 @@ return True -class YajlTestCase(BackendBase): - def setUp(self): - self.set_preferred_backend('yajl') - - def test_backend(self): - expected_pickled = ( - '{"things":[{' - '"py/object":"backend_test.Thing",' - '"name":"data","child":null}' - ']}' - ) - self.assertEncodeDecode(expected_pickled) - - class UJsonTestCase(BackendBase): def setUp(self): self.set_preferred_backend('ujson') @@ -192,8 +178,6 @@ suite.addTest(unittest.makeSuite(JsonTestCase)) suite.addTest(unittest.makeSuite(UJsonTestCase)) suite.addTest(unittest.makeSuite(SimpleJsonTestCase)) - if has_module('yajl'): - suite.addTest(unittest.makeSuite(YajlTestCase)) return suite diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/ecdsa_test.py new/jsonpickle-3.0.2/tests/ecdsa_test.py --- old/jsonpickle-3.0.1/tests/ecdsa_test.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/ecdsa_test.py 2023-01-09 17:13:27.000000000 +0100 @@ -12,9 +12,14 @@ @pytest.fixture(scope='module', autouse=True) def gmpy_extension(): """Initialize the gmpy extension for this test module""" - jsonpickle.ext.gmpy.register_handlers() - yield # control to the test function. - jsonpickle.ext.gmpy.unregister_handlers() + try: + jsonpickle.ext.gmpy.register_handlers() + yield # control to the test function. + jsonpickle.ext.gmpy.unregister_handlers() + except AttributeError: + pytest.skip( + "gmpy was not detected, please try installing it for more complete tests!" + ) class EcdsaTestCase(SkippableTest): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/jsonpickle_test.py new/jsonpickle-3.0.2/tests/jsonpickle_test.py --- old/jsonpickle-3.0.1/tests/jsonpickle_test.py 2022-12-01 17:50:42.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/jsonpickle_test.py 2023-08-13 20:29:11.000000000 +0200 @@ -563,6 +563,14 @@ jsonpickle.decode(encoded, classes={"MyPropertiesSlots": MyPropertiesDict}), ) + def test_warnings(self): + data = os.fdopen(os.pipe()[0]) + with warnings.catch_warnings(record=True) as w: + jsonpickle.encode(data, warn=True) + assert len(w) == 1 + assert issubclass(w[-1].category, UserWarning) + assert "replaced with None" in str(w[-1].message) + class JSONPickleTestCase(SkippableTest): def setUp(self): @@ -719,6 +727,21 @@ self.assertEqual(obj.s, actual.s) self.assertEqual(obj.valid, actual.valid) + def test_dict_subclass_with_references(self): + d = UserDict() + d.s = 'string' + d['s'] = 'test' + obj = [d, d, d.__dict__] + pickle = jsonpickle.encode(obj) + actual = jsonpickle.decode(pickle) + + self.assertEqual(type(actual), list) + self.assertEqual(type(actual[0]), UserDict) + self.assertEqual(actual[0].s, 'string') + self.assertEqual(actual[0]['s'], 'test') + self.assertIs(actual[0], actual[1]) + self.assertIs(actual[0].__dict__, actual[2]) + def test_list_of_objects(self): """Test that objects in lists are referenced correctly""" a = Thing('a') @@ -958,6 +981,12 @@ # TODO: Find a simple example that reproduces #364 self.assertTrue(True) + def test_depth_tracking(self): + l = [] + pickler = jsonpickle.Pickler() + pickler.flatten([l, l, l, l, l]) + self.assertEqual(pickler._depth, -1) + class PicklableNamedTuple(object): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/object_test.py new/jsonpickle-3.0.2/tests/object_test.py --- old/jsonpickle-3.0.1/tests/object_test.py 2022-12-07 17:15:52.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/object_test.py 2023-08-13 20:26:13.000000000 +0200 @@ -122,7 +122,6 @@ class ThingWithSlots(object): - __slots__ = ('a', 'b') def __init__(self, a, b): @@ -131,7 +130,6 @@ class ThingWithInheritedSlots(ThingWithSlots): - __slots__ = ('c',) def __init__(self, a, b, c): @@ -140,7 +138,6 @@ class ThingWithIterableSlots(object): - __slots__ = iter('ab') def __init__(self, a, b): @@ -175,6 +172,25 @@ return self.__class__() +class ThingWithDefaultFactoryRegistry: + """Counts calls to ThingWithDefaultFactory.__init__()""" + + count = 0 # Incremented by ThingWithDefaultFactory(). + + +class ThingWithDefaultFactory: + """Class that ensures that provides a default factory""" + + def __new__(cls, *args, **kwargs): + """Ensure that jsonpickle uses our constructor during initialization""" + return super().__new__(cls, *args, **kwargs) + + def __init__(self): + self.default_factory = self.__class__ + # Keep track of how many times this constructor has been run. + ThingWithDefaultFactoryRegistry.count += 1 + + class IntEnumTest(enum.IntEnum): X = 1 Y = 2 @@ -618,6 +634,19 @@ assert newdefdict.default_factory == list +def test_default_factory_initialization(): + """Ensure that ThingWithDefaultFactory()'s constructor is called""" + thing = ThingWithDefaultFactory() + assert ThingWithDefaultFactoryRegistry.count == 1 + + thing.is_awesome = True + encoded = jsonpickle.encode(thing) + new_thing = jsonpickle.decode(encoded) + + assert ThingWithDefaultFactoryRegistry.count == 2 + assert new_thing.is_awesome + + def test_defaultdict_roundtrip_simple_lambda(): """Make sure we can handle defaultdict(lambda: defaultdict(int))""" # setup a sparse collections.defaultdict with simple lambdas diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/pandas_test.py new/jsonpickle-3.0.2/tests/pandas_test.py --- old/jsonpickle-3.0.1/tests/pandas_test.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/pandas_test.py 2023-08-13 20:26:08.000000000 +0200 @@ -62,7 +62,7 @@ 'an_inf': np.array([np.inf] * 3), 'a_str': np.str_('foo'), 'a_unicode': np.unicode_('bar'), - 'date': np.array([np.datetime64('2014-01-01')] * 3), + 'date': np.array([np.datetime64('2014-01-01')] * 3, dtype="datetime64[s]"), 'complex': np.complex_([1 - 2j, 2 - 1.2j, 3 - 1.3j]), # TODO: the following dtypes are not currently supported. # 'object': np.object_([{'a': 'b'}]*3), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/sklearn_test.py new/jsonpickle-3.0.2/tests/sklearn_test.py --- old/jsonpickle-3.0.1/tests/sklearn_test.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/sklearn_test.py 2023-01-09 17:13:27.000000000 +0100 @@ -4,6 +4,8 @@ try: import numpy as np + import sklearn.datasets + from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier except ImportError: pytest.skip('sklearn is not available', allow_module_level=True) @@ -53,5 +55,22 @@ assert actual.get_depth() == classifier.get_depth() +def test_nested_array_serialization(): + iris = sklearn.datasets.load_iris() + X = iris.data[:, :2] + y = (iris.target != 0) * 1 + + pipe = LogisticRegression(solver="lbfgs") + pipe.fit(X, y) + res = pipe.predict(X) + + # Try serializing/deserializing. + # Pipe is a LogisticRegression object that contains a nested array + js = jsonpickle.dumps(pipe) + pipe2 = jsonpickle.loads(js) + # coef_ only appears on an instance that has already been fit to something + assert np.all(pipe.coef_ == pipe2.coef_) + + if __name__ == '__main__': pytest.main([__file__]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/sqlalchemy_test.py new/jsonpickle-3.0.2/tests/sqlalchemy_test.py --- old/jsonpickle-3.0.1/tests/sqlalchemy_test.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/sqlalchemy_test.py 2023-05-23 01:46:28.000000000 +0200 @@ -16,7 +16,6 @@ HAS_SQA = False if HAS_SQA: - Base = declarative.declarative_base() class Table(Base): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpickle-3.0.1/tests/util_test.py new/jsonpickle-3.0.2/tests/util_test.py --- old/jsonpickle-3.0.1/tests/util_test.py 2022-11-15 01:21:56.000000000 +0100 +++ new/jsonpickle-3.0.2/tests/util_test.py 2023-05-23 01:46:28.000000000 +0200 @@ -30,7 +30,6 @@ class MethodTestClass(object): - variable = None @staticmethod