Skip to content

Commit cea6f52

Browse files
committed
backport of cloudpipe/cloudpickle#145, BUG: Handle instance methods of builtin types.
1 parent e7eabe3 commit cea6f52

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/pyspark/cloudpickle.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,13 @@ def save_function(self, obj, name=None):
329329
Determines what kind of function obj is (e.g. lambda, defined at
330330
interactive prompt, etc) and handles the pickling appropriately.
331331
"""
332-
if obj in _BUILTIN_TYPE_CONSTRUCTORS:
332+
try:
333+
should_special_case = obj in _BUILTIN_TYPE_CONSTRUCTORS
334+
except TypeError:
335+
# Methods of builtin types aren't hashable in python 2.
336+
should_special_case = False
337+
338+
if should_special_case:
333339
# We keep a special-cased cache of built-in type constructors at
334340
# global scope, because these functions are structured very
335341
# differently in different python versions and implementations (for

0 commit comments

Comments
 (0)