Skip to content
Closed
Prev Previous commit
Next Next commit
Re-enable our custom exception message
  • Loading branch information
holdenk committed Jul 25, 2017
commit 9a0f9b4b9958c5fed6d2c84d725cb03a7be7d41e
12 changes: 12 additions & 0 deletions python/pyspark/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import types
import weakref

from pyspark.util import _exception_message

if sys.version < '3':
from pickle import Pickler
Expand Down Expand Up @@ -236,6 +237,17 @@ def dump(self, obj):
if 'recursion' in e.args[0]:
msg = """Could not pickle object as excessively deep recursion required."""
raise pickle.PicklingError(msg)
except pickle.PickleError:
raise
except Exception as e:
emsg = _exception_message(e)
if "'i' format requires" in emsg:
msg = "Object too large to serialize: %s" % emsg
else:
msg = "Could not serialize object: %s: %s" % (e.__class__.__name__, emsg)
print_exec(sys.stderr)
raise pickle.PicklingError(msg)


def save_memoryview(self, obj):
"""Fallback to save_string"""
Expand Down