summaryrefslogtreecommitdiff
path: root/dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-10-17 13:54:39 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-10-17 13:54:39 +0100
commitfe7238eca1d510cb096bf290978af72ba6607930 (patch)
tree564be9d3b7f3c9537d08b9b6a75fb119777c36f3 /dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch
parent403387a1bc2a2d98e75bf1474b21ae379b88aab2 (diff)
gentoo auto-resync : 17:10:2022 - 13:54:39
Diffstat (limited to 'dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch')
-rw-r--r--dev-python/jsonpickle/files/jsonpickle-2.2.0-python3.11.patch46
1 files changed, 46 insertions, 0 deletions
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: