Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.2.2
=====

- Fix a bug affecting bound classmethod saving on Python 2.
([issue #288](https://github.com/cloudpipe/cloudpickle/issues/288))

1.2.1
=====
Expand Down
2 changes: 1 addition & 1 deletion cloudpickle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
if sys.version_info[:2] >= (3, 8):
from cloudpickle.cloudpickle_fast import CloudPickler, dumps, dump

__version__ = '1.3.0.dev0'
__version__ = '1.2.2.dev0'
5 changes: 3 additions & 2 deletions cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,9 @@ def save_instancemethod(self, obj):
if PY3: # pragma: no branch
self.save_reduce(types.MethodType, (obj.__func__, obj.__self__), obj=obj)
else:
self.save_reduce(types.MethodType, (obj.__func__, obj.__self__, obj.__self__.__class__),
obj=obj)
self.save_reduce(
types.MethodType,
(obj.__func__, obj.__self__, type(obj.__self__)), obj=obj)

dispatch[types.MethodType] = save_instancemethod

Expand Down
9 changes: 9 additions & 0 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ def test_cm(cls):
self.assertEqual(A.test_sm(), "sm")
self.assertEqual(A.test_cm(), "cm")

def test_bound_classmethod(self):
class A:
@classmethod
def test_cm(cls):
return "cm"

A.test_cm = pickle_depickle(A.test_cm, protocol=self.protocol)
self.assertEqual(A.test_cm(), "cm")

def test_method_descriptors(self):
f = pickle_depickle(str.upper)
self.assertEqual(f('abc'), 'ABC')
Expand Down