Skip to content

Commit 9b33280

Browse files
committed
Move builtin classmethod_descriptor to a different test
This patch mvoes the builtin classmethod descriptor test to a different one and mark it to skip for python >= 3.10.8. The classmethod descriptor serializarion was removed from python in these releases: https://docs.python.org/3.10/whatsnew/changelog.html#id3 More information in the github issue: python/cpython#95196 Fix cloudpipe#485
1 parent 40aa846 commit 9b33280

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/cloudpickle_test.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -868,21 +868,16 @@ def test_builtin_classicmethod(self):
868868
assert depickled_unbound_meth is unbound_classicmethod
869869
assert depickled_clsdict_meth is clsdict_classicmethod
870870

871-
872871
def test_builtin_classmethod(self):
873872
obj = 1.5 # float object
874873

875874
bound_clsmethod = obj.fromhex # builtin_function_or_method
876875
unbound_clsmethod = type(obj).fromhex # builtin_function_or_method
877-
clsdict_clsmethod = type(
878-
obj).__dict__['fromhex'] # classmethod_descriptor
879876

880877
depickled_bound_meth = pickle_depickle(
881878
bound_clsmethod, protocol=self.protocol)
882879
depickled_unbound_meth = pickle_depickle(
883880
unbound_clsmethod, protocol=self.protocol)
884-
depickled_clsdict_meth = pickle_depickle(
885-
clsdict_clsmethod, protocol=self.protocol)
886881

887882
# float.fromhex takes a string as input.
888883
arg = "0x1"
@@ -893,6 +888,21 @@ def test_builtin_classmethod(self):
893888
assert depickled_bound_meth(arg) == bound_clsmethod(arg)
894889
assert depickled_unbound_meth(arg) == unbound_clsmethod(arg)
895890

891+
@pytest.mark.skipif(
892+
sys.version_info >= (3, 10, 8),
893+
reason="Disabled classmethod_descriptor pickle https://github.com/python/cpython/issues/95196"
894+
)
895+
def test_builtin_classmethod_descriptor(self):
896+
obj = 1.5 # float object
897+
898+
clsdict_clsmethod = type(
899+
obj).__dict__['fromhex'] # classmethod_descriptor
900+
901+
depickled_clsdict_meth = pickle_depickle(
902+
clsdict_clsmethod, protocol=self.protocol)
903+
904+
# float.fromhex takes a string as input.
905+
arg = "0x1"
896906
if platform.python_implementation() == 'CPython':
897907
# Roundtripping a classmethod_descriptor results in a
898908
# builtin_function_or_method (CPython upstream issue).

0 commit comments

Comments
 (0)