commit:     433700e8ebfb60937f7004051f5079379d39e2b2
Author:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 11:07:16 2022 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 11:07:16 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=433700e8

dev-python/jsonpickle: enable python3.11

Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../files/jsonpickle-2.2.0-python3.11.patch        | 46 ++++++++++++++++
 dev-python/jsonpickle/jsonpickle-2.2.0-r1.ebuild   | 63 ++++++++++++++++++++++
 2 files changed, 109 insertions(+)

diff --git a/dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch 
b/dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch
new file mode 100644
index 000000000000..10c266a2a696
--- /dev/null
+++ b/dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch
@@ -0,0 +1,46 @@
+diff --git a/jsonpickle/pickler.py b/jsonpickle/pickler.py
+index 3d391cb..2103e46 100644
+--- a/jsonpickle/pickler.py
++++ b/jsonpickle/pickler.py
+@@ -476,8 +476,12 @@ def _flatten_obj_instance(self, obj):
+ 
+         # Support objects with __getstate__(); this ensures that
+         # both __setstate__() and __getstate__() are implemented
+-        has_getstate = hasattr(obj, '__getstate__')
++        has_own_getstate = (
++            hasattr(type(obj), '__getstate__')
++            and type(obj).__getstate__ is not getattr(object, '__getstate__', 
None)
++        )
+         # not using has_method since __getstate__() is handled separately 
below
++        # Note: on Python 3.11+, all objects have __getstate__.
+ 
+         if has_class:
+             cls = obj.__class__
+@@ -549,7 +553,7 @@ def _flatten_obj_instance(self, obj):
+                 # check that getstate/setstate is sane
+                 if not (
+                     state
+-                    and hasattr(obj, '__getstate__')
++                    and has_own_getstate
+                     and not hasattr(obj, '__setstate__')
+                     and not isinstance(obj, dict)
+                 ):
+@@ -581,7 +585,7 @@ def _flatten_obj_instance(self, obj):
+             if has_getinitargs:
+                 data[tags.INITARGS] = self._flatten(obj.__getinitargs__())
+ 
+-        if has_getstate:
++        if has_own_getstate:
+             try:
+                 state = obj.__getstate__()
+             except TypeError:
+@@ -590,7 +594,8 @@ def _flatten_obj_instance(self, obj):
+                 self._pickle_warning(obj)
+                 return None
+             else:
+-                return self._getstate(state, data)
++                if state:
++                    return self._getstate(state, data)
+ 
+         if util.is_module(obj):
+             if self.unpicklable:

diff --git a/dev-python/jsonpickle/jsonpickle-2.2.0-r1.ebuild 
b/dev-python/jsonpickle/jsonpickle-2.2.0-r1.ebuild
new file mode 100644
index 000000000000..5d7a8f7f0267
--- /dev/null
+++ b/dev-python/jsonpickle/jsonpickle-2.2.0-r1.ebuild
@@ -0,0 +1,63 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{8..11} )
+
+inherit distutils-r1 optfeature
+
+DESCRIPTION="Python library for serializing any arbitrary object graph into 
JSON"
+HOMEPAGE="
+       https://github.com/jsonpickle/jsonpickle/
+       https://pypi.org/project/jsonpickle/
+"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
+
+BDEPEND="
+       dev-python/setuptools_scm[${PYTHON_USEDEP}]
+       test? (
+               dev-python/feedparser[${PYTHON_USEDEP}]
+               dev-python/numpy[${PYTHON_USEDEP}]
+               dev-python/pandas[${PYTHON_USEDEP}]
+               dev-python/simplejson[${PYTHON_USEDEP}]
+               dev-python/sqlalchemy[${PYTHON_USEDEP}]
+               dev-python/ujson[${PYTHON_USEDEP}]
+       )
+"
+
+PATCHES=(
+       # https://github.com/jsonpickle/jsonpickle/pull/396
+       "${FILESDIR}/${P}-python3.11.patch"
+)
+
+distutils_enable_tests pytest
+
+python_prepare_all() {
+       sed -i -e 's:--flake8 --cov::' pytest.ini || die
+       distutils-r1_python_prepare_all
+}
+
+python_test() {
+       local EPYTEST_IGNORE=(
+               # unpackaged bson dependency
+               tests/bson_test.py
+               # broken when gmpy is installed
+               # https://github.com/jsonpickle/jsonpickle/issues/328
+               # https://github.com/jsonpickle/jsonpickle/issues/316
+               tests/ecdsa_test.py
+       )
+       epytest
+}
+
+pkg_postinst() {
+       # Unpackaged optional backends: yajl, demjson
+       optfeature "encoding numpy-based data" dev-python/numpy
+       optfeature "encoding pandas objects" dev-python/pandas
+       optfeature "fast JSON backend" dev-python/simplejson
+}

Reply via email to