Skip to content

Commit

Permalink
FIX do not override Pickler's dispatch_table (#203)
Browse files Browse the repository at this point in the history
If a Pickler instance already has methods in its dispatch table, do not
override them. This bug showed up in
cloudpipe/cloudpickle#253, where the
Cloudpickler instances derives from the C Pickler, and most custom
saving methods are inside dispatch_table, not dispatch.
  • Loading branch information
pierreglaser authored and tomMoral committed Mar 18, 2019
1 parent 1f5f77e commit 34d8fd0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion loky/backend/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ def __init__(self, writer, reducers=None, protocol=HIGHEST_PROTOCOL):
if sys.version_info < (3,):
self.dispatch = self._dispatch.copy()
else:
self.dispatch_table = self._dispatch_table.copy()
if getattr(self, "dispatch_table", None) is not None:
self.dispatch_table.update(self._dispatch_table.copy())
else:
self.dispatch_table = self._dispatch_table.copy()

for type, reduce_func in reducers.items():
self.register(type, reduce_func)

Expand Down

0 comments on commit 34d8fd0

Please sign in to comment.