Skip to content

Commit df6ab36

Browse files
committed
fix missing is_dill guards from #463
1 parent 6cafbf1 commit df6ab36

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

dill/_dill.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ def _import_module(import_name, safe=False):
11021102

11031103
def _locate_function(obj, pickler=None):
11041104
if obj.__module__ in ['__main__', None] or \
1105-
pickler and pickler._session and obj.__module__ == pickler._main.__name__:
1105+
pickler and is_dill(pickler, child=False) and pickler._session and obj.__module__ == pickler._main.__name__:
11061106
return False
11071107

11081108
found = _import_module(obj.__module__ + '.' + obj.__name__, safe=True)
@@ -1893,6 +1893,7 @@ def save_function(pickler, obj):
18931893
_byref = getattr(pickler, '_byref', None)
18941894
_postproc = getattr(pickler, '_postproc', None)
18951895
_main_modified = getattr(pickler, '_main_modified', None)
1896+
_original_main = getattr(pickler, '_original_main', __builtin__)#'None'
18961897
postproc_list = []
18971898
if _recurse:
18981899
# recurse to get all globals referred to by obj
@@ -1907,10 +1908,11 @@ def save_function(pickler, obj):
19071908
else:
19081909
globs_copy = obj.__globals__ if PY3 else obj.func_globals
19091910

1910-
# If the globals is the __dict__ from the module being save as a
1911+
# If the globals is the __dict__ from the module being saved as a
19111912
# session, substitute it by the dictionary being actually saved.
1912-
if _main_modified and globs_copy is pickler._original_main.__dict__:
1913-
globs = globs_copy = pickler._main.__dict__
1913+
if _main_modified and globs_copy is _original_main.__dict__:
1914+
globs_copy = getattr(pickler, '_main', _original_main).__dict__
1915+
globs = globs_copy
19141916
# If the globals is a module __dict__, do not save it in the pickle.
19151917
elif globs_copy is not None and obj.__module__ is not None and \
19161918
getattr(_import_module(obj.__module__, True), '__dict__', None) is globs_copy:

0 commit comments

Comments
 (0)