From 872dfbfd5766134cf4683e1cc79bb130f807965b54d02546ad5aef5dcb8f6bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Fri, 15 Mar 2019 13:07:06 +0000 Subject: [PATCH 1/2] - Update to 1.1: * Python 3.7 collections.Iterator deprecation warnings have been fixed. (#229). * Improved Pandas support for datetime and complex numbers. (#245) * NOTE jsonpickle no longer supports Python2.6, or Python3 < 3.4. The officially supported Python versions are now 2.7 and 3.4+. * Improved Pandas and Numpy support. (#227) * Improved support for pickling iterators. (#216) * Better support for the stdlib json module when simplejson is not installed. (#217) * jsonpickle will now output python3-style module names when pickling builtins methods or functions. (#223) * jsonpickle will always flatten primitives, even when max_depth is reached, which avoids encoding unicode strings into their u'string' representation. * Nested classes are now supported on Python 3. (#206, #176). * Better support for older (pre-1.9) versions of numpy (#195). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-jsonpickle?expand=0&rev=7 --- jsonpickle-0.9.6.tar.gz | 3 --- jsonpickle-1.1.tar.gz | 3 +++ python-jsonpickle.changes | 15 +++++++++++++++ python-jsonpickle.spec | 12 ++++++------ 4 files changed, 24 insertions(+), 9 deletions(-) delete mode 100644 jsonpickle-0.9.6.tar.gz create mode 100644 jsonpickle-1.1.tar.gz diff --git a/jsonpickle-0.9.6.tar.gz b/jsonpickle-0.9.6.tar.gz deleted file mode 100644 index a05e0a6..0000000 --- a/jsonpickle-0.9.6.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:545b3bee0d65e1abb4baa1818edcc9ec239aa9f2ffbfde8084d71c056180054f -size 67137 diff --git a/jsonpickle-1.1.tar.gz b/jsonpickle-1.1.tar.gz new file mode 100644 index 0000000..15378ec --- /dev/null +++ b/jsonpickle-1.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:625098cc8e5854b8c23b587aec33bc8e33e0e597636bfaca76152249c78fe5c1 +size 71602 diff --git a/python-jsonpickle.changes b/python-jsonpickle.changes index 453d482..c21b683 100644 --- a/python-jsonpickle.changes +++ b/python-jsonpickle.changes @@ -1,3 +1,18 @@ +------------------------------------------------------------------- +Fri Mar 15 13:00:30 UTC 2019 - Tomáš Chvátal + +- Update to 1.1: + * Python 3.7 collections.Iterator deprecation warnings have been fixed. (#229). + * Improved Pandas support for datetime and complex numbers. (#245) + * NOTE jsonpickle no longer supports Python2.6, or Python3 < 3.4. The officially supported Python versions are now 2.7 and 3.4+. + * Improved Pandas and Numpy support. (#227) + * Improved support for pickling iterators. (#216) + * Better support for the stdlib json module when simplejson is not installed. (#217) + * jsonpickle will now output python3-style module names when pickling builtins methods or functions. (#223) + * jsonpickle will always flatten primitives, even when max_depth is reached, which avoids encoding unicode strings into their u'string' representation. + * Nested classes are now supported on Python 3. (#206, #176). + * Better support for older (pre-1.9) versions of numpy (#195). + ------------------------------------------------------------------- Tue Dec 4 12:49:37 UTC 2018 - Matej Cepl diff --git a/python-jsonpickle.spec b/python-jsonpickle.spec index a5272c1..150e4df 100644 --- a/python-jsonpickle.spec +++ b/python-jsonpickle.spec @@ -1,7 +1,7 @@ # # spec file for package python-jsonpickle # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 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 @@ -18,9 +18,9 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-jsonpickle -Version: 0.9.6 +Version: 1.1 Release: 0 -Url: http://jsonpickle.github.com/ +Url: https://github.com/jsonpickle/jsonpickle Summary: Python library for serializing any arbitrary object graph into JSON License: BSD-3-Clause Group: Development/Languages/Python @@ -31,9 +31,9 @@ BuildRequires: python-rpm-macros # SECTION test requirements BuildRequires: %{python_module SQLAlchemy} BuildRequires: %{python_module coverage} -BuildRequires: %{python_module nose} BuildRequires: %{python_module numpy} BuildRequires: %{python_module pymongo} +BuildRequires: %{python_module pytest} # /SECTION # SECTION python 2 test requirements BuildRequires: python-enum34 @@ -65,10 +65,10 @@ Additionally, it can reconstitute the object back into Python. %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_expand nosetests-%{$python_bin_suffix} +%pytest %files %{python_files} -%doc README.rst +%doc README.rst docs/source/changelog.rst %license COPYING %{python_sitelib}/* From 3b3c66c6af5ace0a1eb0e80c2e140644e1b7d53e16315316729be619b41d8988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 19 Mar 2019 08:20:58 +0000 Subject: [PATCH 2/2] - Add patch to work with sqlalchemy 1.3: * sqlalchemy13.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-jsonpickle?expand=0&rev=8 --- python-jsonpickle.changes | 6 +++ python-jsonpickle.spec | 12 +++--- sqlalchemy13.patch | 84 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 sqlalchemy13.patch diff --git a/python-jsonpickle.changes b/python-jsonpickle.changes index c21b683..2066463 100644 --- a/python-jsonpickle.changes +++ b/python-jsonpickle.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Mar 19 08:12:54 UTC 2019 - Tomáš Chvátal + +- Add patch to work with sqlalchemy 1.3: + * sqlalchemy13.patch + ------------------------------------------------------------------- Fri Mar 15 13:00:30 UTC 2019 - Tomáš Chvátal diff --git a/python-jsonpickle.spec b/python-jsonpickle.spec index 150e4df..5e9dd43 100644 --- a/python-jsonpickle.spec +++ b/python-jsonpickle.spec @@ -20,14 +20,19 @@ Name: python-jsonpickle Version: 1.1 Release: 0 -Url: https://github.com/jsonpickle/jsonpickle Summary: Python library for serializing any arbitrary object graph into JSON License: BSD-3-Clause Group: Development/Languages/Python +URL: https://github.com/jsonpickle/jsonpickle Source: https://files.pythonhosted.org/packages/source/j/jsonpickle/jsonpickle-%{version}.tar.gz +Patch0: sqlalchemy13.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros +Recommends: python-simplejson +Suggests: python-demjson +Suggests: python-ujson +Suggests: python-yajl # SECTION test requirements BuildRequires: %{python_module SQLAlchemy} BuildRequires: %{python_module coverage} @@ -38,10 +43,6 @@ BuildRequires: %{python_module pytest} # SECTION python 2 test requirements BuildRequires: python-enum34 # /SECTION -Recommends: python-simplejson -Suggests: python-demjson -Suggests: python-ujson -Suggests: python-yajl # SECTION python 2 requirements Suggests: python-feedparser Suggests: python-jsonlib @@ -56,6 +57,7 @@ Additionally, it can reconstitute the object back into Python. %prep %setup -q -n jsonpickle-%{version} +%patch0 -p1 %build %python_build diff --git a/sqlalchemy13.patch b/sqlalchemy13.patch new file mode 100644 index 0000000..fd294d5 --- /dev/null +++ b/sqlalchemy13.patch @@ -0,0 +1,84 @@ +From 838c29e43267e3578d077698386e1adbcc0657c5 Mon Sep 17 00:00:00 2001 +From: David Aguilar +Date: Mon, 18 Mar 2019 22:32:54 -0700 +Subject: [PATCH] unpickler: better support for sqlalchemy >= 1.3 + +The _safe_hasattr() workaround for older versions of SQLAlchemy +surprisingly breaks newer versions. + +Be optimistic and catch the runtime error so that newer versions do not +incur the cost of the original workaround. The older versions are still +supported since they'll land in the old code path. + +This is justifiable since it's a generic code path and will speed up +things for 99% of the other objects out there, including newer +sqlalchemy versions. + +Closes #254 +Signed-off-by: David Aguilar +--- + jsonpickle/unpickler.py | 11 +++++++++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/jsonpickle/unpickler.py b/jsonpickle/unpickler.py +index f0a93d1..40af4e0 100644 +--- a/jsonpickle/unpickler.py ++++ b/jsonpickle/unpickler.py +@@ -42,8 +42,15 @@ def decode(string, backend=None, context=None, keys=False, reset=True, + + + def _safe_hasattr(obj, attr): +- """A safe (but slow) hasattr() that avoids hasattr""" +- return attr in dir(obj) ++ """Workaround unreliable hasattr() availability on sqlalchemy objects""" ++ try: ++ # In sqlalchemy >= 1.3 we can use hasattr(). ++ return hasattr(obj, attr) ++ except RuntimeError: ++ # In older versions we use a safe (but slow) method to avoid hasattr(). ++ # Older versions of sqlalchemy hit maximum recursion errors during ++ # deserialization. The workaround is to avoid hasattr(). ++ return attr in dir(obj) + + + class _Proxy(object): +From 670b678a109a7fab91e3e50fb35f65bf75aff1e9 Mon Sep 17 00:00:00 2001 +From: David Aguilar +Date: Tue, 19 Mar 2019 00:21:19 -0700 +Subject: [PATCH] unpickler: make _safe_hasattr() even safer + +Use object.__getattribute__() to implement our hasattr() workaround, +which is even more robust (and performant) than the previous solution. + +The old version did work on Python2, but Python3 is unable to catch +recursion +errors so a better solution was needed. + +Related-to: #254 +Signed-off-by: David Aguilar +--- + jsonpickle/unpickler.py | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/jsonpickle/unpickler.py b/jsonpickle/unpickler.py +index 40af4e0..e1f9e75 100644 +--- a/jsonpickle/unpickler.py ++++ b/jsonpickle/unpickler.py +@@ -44,13 +44,10 @@ def decode(string, backend=None, context=None, keys=False, reset=True, + def _safe_hasattr(obj, attr): + """Workaround unreliable hasattr() availability on sqlalchemy objects""" + try: +- # In sqlalchemy >= 1.3 we can use hasattr(). +- return hasattr(obj, attr) +- except RuntimeError: +- # In older versions we use a safe (but slow) method to avoid hasattr(). +- # Older versions of sqlalchemy hit maximum recursion errors during +- # deserialization. The workaround is to avoid hasattr(). +- return attr in dir(obj) ++ object.__getattribute__(obj, attr) ++ return True ++ except AttributeError: ++ return False + + + class _Proxy(object):