Skip to content

Commit

Permalink
DOC document __builtins__ of modules are not pickled
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreglaser committed Jun 19, 2021
1 parent 8471ca3 commit 4d45d6e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cloudpickle/cloudpickle_fast.py
Expand Up @@ -342,6 +342,10 @@ def _module_reduce(obj):
if _is_importable(obj):
return subimport, (obj.__name__,)
else:
# Some external libraries can populate the "__builtins__" entry of a
# module's `__dict__` with unpicklable objects (see #316). For that
# reason, we do not attempt to pickle the "__builtins__" entry, and
# restore a default value for it at unpickling time.
state = obj.__dict__.copy()
state.pop('__builtins__', None)
return dynamic_subimport, (obj.__name__, state)
Expand Down

0 comments on commit 4d45d6e

Please sign in to comment.