Skip to content

Commit

Permalink
fix dump_session(byref=True) bug when the multiprocessing module …
Browse files Browse the repository at this point in the history
…was imported

Just calling `import multiprocessing` creates a `'__mp_main__'` entry in `sys.modules` that is simply a reference to the `__main__` module. In the old version of the test for module membership, objects in the global scope are wrongly attributed to this virtual `__mp_main__` module. And therefore `load_session()` fails. Testing for object identity instead of module name resolves the issue.
  • Loading branch information
leogama authored Apr 22, 2022
1 parent b98cd44 commit 44a9e54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dill/_dill.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _module_map():
def _lookup_module(modmap, name, obj, main_module): #FIXME: needs work
"""lookup name if module is imported"""
for modobj, modname in modmap[name]:
if modobj is obj and modname != main_module.__name__:
if modobj is obj and sys.modules[modname] is not main_module:
return modname

def _stash_modules(main_module):
Expand Down

0 comments on commit 44a9e54

Please sign in to comment.